Skip to content

Commit

Permalink
ActiveRecord::RecordNotFound for missing pages
Browse files Browse the repository at this point in the history
Currently a missing page errors in `show` on `should_skip_to_first_child?` because page is nil.
`find_by!` will raise ActiveRecord::RecordNotFound and halt the action and cause a 404
  • Loading branch information
DanBrooker committed Jan 19, 2016
1 parent dfb993c commit 3785c62
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/spina/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def rewrite_page
end

def page
@page ||= (action_name == 'homepage') ? Page.find_by(name: 'homepage') : Page.find_by(materialized_path: "/" + params[:id])
@page ||= (action_name == 'homepage') ? Page.find_by!(name: 'homepage') : Page.find_by!(materialized_path: "/" + params[:id])
end
helper_method :page

Expand Down

0 comments on commit 3785c62

Please sign in to comment.