【发布时间】:2016-04-28 06:25:27
【问题描述】:
我无法通过 Heroku 让我的应用在生产环境中运行。它是一个正在开发中的完全可用的应用程序。
我在 SO 上研究了这个问题,但许多解决方案是因为他们的 routes.rb 中有重复的 devise_for。我的应用程序没有这个问题,而且我很难找出这种重复发生的位置。
这是完整的错误信息:
/app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.4/lib/action_dispatch/routing/route_set.rb:557: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
这是我当前的routes.rb 文件:
Rails.application.routes.draw do
devise_for :users, :controllers => { registrations: 'registrations' }
get 'items/create'
get 'welcome/index'
get 'about' => 'welcome#about'
get 'brandon' => 'welcome#brandon'
root 'welcome#index'
resources :users, only: [:index, :show] do
resources :items
end
end
我已经更新了我的 gem,删除了数据库并重新迁移,但没有任何效果。
【问题讨论】:
-
可能不相关,但您的前两个 GET 路由未显示要定向到哪个控制器和操作,也请尝试将您的根放在 devise_for 路由下方。
标签: ruby-on-rails ruby heroku routes precompile