重定向设计before_filter:authenticate_user以登录路径

Gle*_*enn 23 ruby-on-rails devise

我正在使用设计并有一个快速的问题.如何重定向:authenticate_user!before_filter到用户注册页面而不是登录?我一直在浏览https://github.com/plataformatec/devise/blob/master/lib/devise/controllers/helpers.rb但是没有太多运气找出解决方案.

Bac*_*507 44

我有一个类似的问题,其中我需要重定向到注册如果用户没有登录,我通过向application_controller.rb的方法和使用它作为在其它控制器过滤器之前固定它.

请记住,这是一个临时解决方案,因为它会跳过一堆设计抽象.


before_filter :auth_user

  def auth_user
    redirect_to new_user_registration_url unless user_signed_in?
  end


Ste*_*eve 9

您将不得不创建一个继承自Devise的FailureApp的自定义FailureApp,如下所示:https://github.com/plataformatec/devise/wiki/How-To :-Redirect-to-a-specific-page-when -the-用户可以-不进行身份验证