I would like it, if after a user logs in, that it automatically redirect to their previous location, but this never seems to happen, it always redirects back to the root location. From reading the docs on devise for this it seems this functionality is supposed to just work. Am I using it somehow wrongly and/or how can I force it to store the location and redirect regardless?
http://rubydoc.info/github/plataformatec/devise/master/Devise/Controllers/Helpers#stored_location_for-instance_method
authentication = UserToken.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])
if authentication
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => omniauth['provider']
sign_in_and_redirect(:user, authentication.user)
else
Scroll to the bottom of this Google group page and check out the overridden 'stored_location_for' devise method. I have an adapted version of it in my application_controller that looks like this:
def stored_location_for(resource)
if current_user && params[:redirect_to]
flash[:notice] = "Congratulations, you're signed up!"
return params[:redirect_to]
end
super( resource )
end
That should let you create the location manually by passing in a 'redirect_to' param.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With