diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 35900bd..c084e08 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,6 +1,8 @@ class ApplicationController < ActionController::Base protect_from_forgery + rescue_from ActiveRecord::RecordNotFound, :with => :render_404 + def after_sign_in_path_for(resource_or_scope) admin_dashboard_path end @@ -9,4 +11,8 @@ class ApplicationController < ActionController::Base new_admin_user_session_path end + def render_404 + render 'errors/not_found', :status => 404 + end + end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index e1a428a..4535c83 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,6 +1,6 @@ class PagesController < ApplicationController def show - @page = Page.find_by_name(params[:name]) + @page = Page.find_by_name!(params[:name]) @page_title = @page.title end end diff --git a/app/views/errors/not_found.html.erb b/app/views/errors/not_found.html.erb new file mode 100644 index 0000000..3d0ed0e --- /dev/null +++ b/app/views/errors/not_found.html.erb @@ -0,0 +1 @@ +