Skip to content

Commit

Permalink
Make the citation controller's "show" action throw an
Browse files Browse the repository at this point in the history
ActiveRecord::RecordNotFound exception when the given model is not found, just
as all the other controllers do.

This fixes issue PecanProject#668.
  • Loading branch information
gsrohde committed Aug 9, 2019
1 parent 8ac278c commit e55b2cb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/controllers/citations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ def index
# GET /citations/1
# GET /citations/1.xml
def show
@citation = Citation.where(:id => params[:id]).includes(params[:include]).first
# find_by! throws an ActiveRecord::RecordNotFound exception if no citation
# with the given id exists so that we don't attempt to display a nil
# citation.
@citation = Citation.includes(params[:include]).find_by!(:id => params[:id])

respond_to do |format|
format.html # show.html.erb
Expand Down

0 comments on commit e55b2cb

Please sign in to comment.