ruby on rails
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.
链接地址: http://www.djcxy.com/p/49014.html上一篇: >主人(分支目前被检出)'
下一篇: 红宝石在轨道上