Skip to content

Commit e55b2cb

Browse files
committed
Make the citation controller's "show" action throw an
ActiveRecord::RecordNotFound exception when the given model is not found, just as all the other controllers do. This fixes issue #668.
1 parent 8ac278c commit e55b2cb

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

app/controllers/citations_controller.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ def index
123123
# GET /citations/1
124124
# GET /citations/1.xml
125125
def show
126-
@citation = Citation.where(:id => params[:id]).includes(params[:include]).first
126+
# find_by! throws an ActiveRecord::RecordNotFound exception if no citation
127+
# with the given id exists so that we don't attempt to display a nil
128+
# citation.
129+
@citation = Citation.includes(params[:include]).find_by!(:id => params[:id])
127130

128131
respond_to do |format|
129132
format.html # show.html.erb

0 commit comments

Comments
 (0)