ruby-on-rails - Rails 4 + Devise : Invalid route name, 已在使用中

标签 ruby-on-rails ruby devise

我正在按照此操作方法在成功注册后修改确认页面。

https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-on-successful-sign-up-(registration)

我按照它所说的做了所有事情,但我得到了这个错误:

in `add_route': Invalid route name, already in use: 'new_user_session'  (ArgumentError)
You may have defined two routes with the same name using the `:as` option, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes created with `resources` as explained here: 
http://guides.rubyonrails.org/routing.html#restricting-the-routes-created

我猜 wiki 没有针对使用 Devise 和 Rails 4 进行更新,但我没有找到足够的信息来修复错误。

返回错误的行是下一个(routes.rb):

devise_for :users, :controllers => { :registrations => "registrations" }

有什么建议吗?

谢谢。

编辑——

registrations_controller.rb

class RegistrationsController < Devise::RegistrationsController

    protected

    def after_inactive_sign_up_path_for(resource)
        '/sign_up/inactive'
    end
end

路线.rb

root :to => 'home#index'
devise_for :users
resources :users

devise_for :users, :controllers => { :registrations => "registrations" }

最佳答案

您的 routes.rb 中有两条路线 devise_for :users - 删除第一个。

关于ruby-on-rails - Rails 4 + Devise : Invalid route name, 已在使用中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18016761/

相关文章:

ruby-on-rails - Rails 模型字段列表

ruby - 如何将散列保存到 CSV 中

ruby-on-rails - 将设计用户表拆分为两个表

ruby-on-rails - 将事件管理员登录重定向到设计登录

ruby-on-rails - 为什么 rake 任务存储在 lib/tasks/中?

ruby-on-rails - 在数据库中存储正则表达式

ruby - 如何阻止上帝留下陈旧的 Resque 工作流程?

ruby-on-rails - LDAP:未授权,因为在 devise_ldap_authenticatable 上设置 ldap 时未通过身份验证

ruby-on-rails - Pundit::AuthorizationNotPerformedError 与设计 Controller

html - 文本区助手,如何设置最大长度