Skip to content

Instantly share code, notes, and snippets.

@Irostovsky
Created April 21, 2017 11:14
Show Gist options
  • Save Irostovsky/44f3f20d949e2b03f9d8099eb64e930a to your computer and use it in GitHub Desktop.
Save Irostovsky/44f3f20d949e2b03f9d8099eb64e930a to your computer and use it in GitHub Desktop.
AuthenticityTokenCatcher
module AuthenticityTokenCatcher
extend ActiveSupport::Concern
included do
rescue_from ActionController::InvalidAuthenticityToken do |exception|
if request.referrer
flash[:error] = I18n.t :authenticit_token_error
redirect_to request.referrer
else
raise exception
end
end
end
end
#module Users
# class SessionsController < Devise::SessionsController
# include AuthenticityTokenCatcher
# .........
# end
#end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment