ruby-on-rails – 设计sign_in_and_redirect似乎永远不会起作用

我想,如果在用户登录后,它会自动重定向到以前的位置,但这似乎永远不会发生,它总是会重定向回根位置.从阅读有关设计的文档看来,这个功能似乎只是起作用.我是以某种方式错误地使用它和/或我如何强制它存储位置和重定向无论如何?

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

解决方法

滚动到 this Google group page底部并查看被覆盖的’stored_location_for’设计方法.我的application_controller中有一个改编版本,如下所示:
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

这应该让你通过传入’redirect_to’参数手动创建位置.

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...