我无法让我的应用程序通过Heroku在生产环境中运行。它是开发中可以完全使用的应用程序。
我在SO上研究了这个问题,但是许多解决方案是由于devise_for
中的routes.rb
重复。我的应用程序没有这个问题,而且我很难找出发生此重复的地方。
这是完整的错误消息:
/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
我已经更新了我的宝石,删除了数据库并重新迁移它,但没有任何效果。
#config/routes.rb
Rails.application.routes.draw do
resources :items, only: [:new, :create], path_names: { new: "create" }
resources :welcome, path: "", only: :index do #-> url.com/
collection do
get :about #-> url.com/about
get :brandon #-> url.com/brandon
end
end
resources :users, only: [:index, :show] do #-> there may be a conflict with "/users/" as devise also uses "/users/" path
resources :items #-> url.com/users/:user_id/items
end
devise_for :users, controllers: { registrations: 'registrations' }
root "welcome#index"
end
如果不起作用,我将删除它;您可能对自己的“裸”声明有疑问(始终尝试在resources
周围确定路线范围),或者在生产环境中有冲突的文件。
我也遇到类似的情况。devise_for的as选项的使用为我解决了。
resources