4

我的设计有问题。当用户已经登录,然后单击登录链接时,什么也没有发生,但这里是我的终端中的输出:

Filter chain halted as :require_no_authentication rendered or redirected

这发生在我要去的时候Processing by SessionsController#new as HTML

after_sign_in_path有什么办法,如果有登录用户,我怎么能告诉设计去?

这是我的 after_sign_in_path

def after_sign_in_path_for(resource)
    if session[:user_return_to]
      return_to = session[:user_return_to]
      session[:user_return_to] = nil
      return_to
    else
      redirect_path(resource)
    end
end
4

2 回答 2

0
def after_sign_in_path_for(resource)
    if (return_to = session[:user_return_to])
      session[:user_return_to] = nil
      return_to
      return
    else
      redirect_path(resource)
    end
end

我不确定这是否有效,但也许可以使用 after_filter

于 2013-03-20T14:36:33.870 回答
0

也许您应该考虑在控制器之前添加一个过滤器?

prepend_before_filter :require_no_authentication, :only => [:action1, :action2]
于 2013-03-20T13:33:03.803 回答