Last active
August 29, 2015 14:09
-
-
Save salkar/ff87c13c6b2175cdc10f to your computer and use it in GitHub Desktop.
Ruby on Rails: Return back if it is possible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To after_sign_in_path_for(resource) in ApplicationController | |
if request.env['HTTP_REFERER'] | |
begin | |
route_params = Rails.application.routes.recognize_path(URI(request.referrer).path, {method: :get}) | |
if route_params[:controller].include?('devise') | |
root_path | |
else | |
request.env['HTTP_REFERER'] | |
end | |
rescue | |
root_url | |
end | |
else | |
root_url | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment