2017-02-16 49 views
0

我在設置新版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 
+2

你的'routes.rb'看起來像什麼? – Iceman

+0

添加到發佈 – stoerebink

+1

在創建新的rails應用程序之後您是否添加了'devise',或者您是否在任何地方更改了任何內容? – Iceman

回答

0

您沒有任何路線定義,它們都被註釋掉了。取消註釋根路由,例如更改

# root 'welcome#index' 

    root 'welcome#index' 
+0

這不是爲什麼「設計」不起作用 – Iceman

-1

更改您的路線。如上所述設置 確保您有一個名爲控制器歡迎光臨用模板和行動「索引」 然後用root =>歡迎#指數將指向作用。

運行

rails generate devise:install 

運行

rails g devise Model 

這將自動爲您示範路由添加到的routes.rb文件

運行rake db:migrate或與rails5 rails db:migrate 比你有創建模型與設計。

0

我做了一個新的安裝在一個新的目錄,沒有更多的問題。