Im using devise with omniauth for signing in users with facebook. I want them to be redirected after signing in to the page they were on after before signing in.
I\'
You can pass a parameter like: /auth/facebook?referrer=/path/to/redirect
After the Facebook authentication this parameter will be available to you in env["omniauth.params"]
.
I answered this here
Devise doesn't redirect properly to stored location when using omniauth provider like facebook
in application_controller.rb
def after_sign_in_path_for(resource_or_scope)
if request.env['omniauth.origin']
request.env['omniauth.origin']
end
end
did you consider the Devise provided helper sign_in_and_redirect(resource_or_scope, *args)
(details can be found here)? You also get sign_out_and_redirect(resource_or_scope)
amongst others.
Q2. do try inspecting session[:return_to]
- it's most likely nil
.