Skip to content

Instantly share code, notes, and snippets.

@prakashmurthy
Created May 5, 2015 16:30
Show Gist options
  • Save prakashmurthy/476423678fa517537445 to your computer and use it in GitHub Desktop.
Save prakashmurthy/476423678fa517537445 to your computer and use it in GitHub Desktop.
catching ActionController::InvalidAuthenticityToken
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
rescue_from ActionController::InvalidAuthenticityToken, with: :show_errors
before_filter { |c| User.current_user = c.current_user }
...
private
def show_errors
logger.info "\n###\n Came to show errors method! flash: #{flash.inspect}\n###\n"
flash.keep[:notice] = "She has some cookies for you"
redirect_to home_url, alert: "Cookies are bad!"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment