Commit 6e694a3d

mo khan <mo@mokhan.ca>
2014-08-24 20:23:01
catch all record not found and redirect to home page.
1 parent 7bb03a7
Changed files (1)
app/controllers/application_controller.rb
@@ -6,6 +6,7 @@ class ApplicationController < ActionController::Base
   before_filter :configure_permitted_parameters, if: :devise_controller?
   before_filter :extend_session_cookie
   helper_method :current_user, :user_signed_in?
+  rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
 
   def user_session(session_key = cookies.signed[:raphael])
     @user_session ||= UserSession.authenticate(session_key)
@@ -41,4 +42,8 @@ class ApplicationController < ActionController::Base
   def extend_session_cookie
     cookies.signed[:raphael] = user_session.access(request) if user_signed_in?
   end
+
+  def record_not_found
+    redirect_to root_path, status: :moved_permanently
+  end
 end