我遇到了在新的rails应用程序中设置设计的问题。我刚刚创建了一个新的Rails应用程序,添加了设计宝石并运行bundle install
。现在,当我尝试运行rails generate devise:install
时,我收到此错误:
/Users/Bobo/.rvm/gems/ruby-2.2.4/gems/actionpack-4.2.3/lib/action_dispatch/routing/route_set.rb:557:in `add_route': Invalid route name, already in use: 'new_user_session'
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.
我很困惑,我还没有触及我的路线文件,当我运行rake:routes
时它说:You don't have any routes defined!
为什么我收到此错误?这实际上是我采取的第一步..
编辑:我的路线文件
Rails.application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end
答案 0 :(得分:0)
您没有定义任何路线,它们都被注释掉了。取消注释根路由,例如变化
# root 'welcome#index'
root 'welcome#index'
答案 1 :(得分:0)
我在新目录中进行了全新安装,没有其他问题。
答案 2 :(得分:-1)
更改路线。如上所述,设置 root 确保您有一个名为 WELCOME 的控制器,其中包含模板和操作' index' 然后root => welcome #index将指向该操作。
运行
rails generate devise:install
运行
rails g devise Model
这会自动将您的Model的路线添加到routes.rb文件
使用rails5 rake db:migrate
运行rails db:migrate
或
比你用Devise创建一个Model。