我正在使用带有devise和rails 4的rspec,我收到以下错误。
无效的路由名称,已在使用中:'root'(ArgumentError)
您可能使用:as
选项定义了两个具有相同名称的路由,或者您可能正在覆盖已由具有相同命名的资源定义的路由。对于后者,您可以限制使用resources
创建的路由,如下所述:
我只在路线文件中使用“root”一次。当我删除除了'root to:'之外的所有路由时,我仍然会得到相同的错误,当我注释掉'root to:'行时。错误消失了,我的测试运行了。以下是我的路线文件
First_Website::Application.routes.draw do
#root :to => 'static_pages#home'
resources :authentications, only: [:new, :destroy]
devise_for :users, :controllers => { :registrations => 'registrations' }
resources :skills do
get :autocomplete_skilllabel_label, :on => :collection, :formats => "js"
end
scope module: 'survey/tech' do
resources :word_processing_fluentcies, :formats => "js"
resources :word_processing_skills, :formats => "js"
resources :basic_computer_skills, :formats => "js"
resources :operating_systems_usages, :formats => "js"
resources :operating_systems_fluents, :formats => "js"
resources :advanced_computer_skills, :formats => "js"
resources :multi_media_skills, :formats => "js"
resources :technology_differences, :formats => "js"
resources :spreadsheet_skills, :formats => "js"
resources :spreadsheet_fluentcies, :formats => "js"
resources :presenting_skills, :formats => "js"
resources :presenting_fluentcies, :formats => "js"
resources :email_skills, :formats => "js"
resources :email_fluentcies, :formats => "js"
resources :internet_terms, :formats => "js"
resources :internet_tasks, :formats => "js"
resources :internet_connections, :formats => "js"
resources :browsers, :formats => "js"
resources :social_media_skills, :formats => "js"
resources :social_media_descs, :formats => "js"
resources :social_media_platforms, :formats => "js"
resources :online_colab_skills, :formats => "js"
resources :online_colab_fluentcies, :formats => "js"
end
scope module: 'survey/profile' do
resources :languages , :formats => "js"
resources :surveyprofiles
end
scope module: 'survey/personality' do
resources :communication_skills, :formats => "js"
resources :thinking_skills, :formats => "js"
resources :self_direction_skills, :formats => "js"
resources :accountabilities, :formats => "js"
resources :interpersonal_skills, :formats => "js"
end
resources :experiences
resources :references
resources :postings
resources :projects
resources :links
resources :profile
resources :progresses
resources :endorses
resources :photos
resources :shopping_lists
resources :flagged_candidates
resources :flagged_jobs
resources :surveys do
member do
get :back, :formats => "js"
end
end
resources :friendships, only: [:new, :create, :destroy]
resources :messages
resources :network_searches
resources :layouts
resources :experiencetables do
member do
patch :vol_update, :formats => "js"
patch :ft_update, :formats => "js"
patch :pt_update, :formats => "js"
patch :employ_update, :formats => "js"
end
end
match '/show_network', to:'friendships#show', via: 'get'
match '/ft_update', to: 'experiencetables#ft_update', via: 'get'
match '/pt_update', to: 'experiencetables#pt_update', via: 'get'
match '/vol_update', to: 'experiencetables#vol_update', via: 'get'
match '/employ_update', to: 'experiencetables#employ_update', via: 'get'
match '/search', to: 'search#search', via: 'get'
match '/findfriend', to: 'friendships#findfriend', via: 'get'
match '/findcompany', to: 'friendships#findcompany', via: 'get'
match '/results', to: 'surveys#add', via: 'post'
match '/reccomended', to: 'skills#reccomend', via:'get'
match '/details', to: 'experiences#details', via: 'get'
match '/one_ref', to: 'references#one_ref', via: 'get'
match '/add_exp', to: "experiences#add", via: 'get'
match '/resume', to: "profile#resume", via: 'get'
get 'privatechat', to: "layouts#privatechat", via: 'get'
match '/auth/:provider/callback', to: 'authentications#create', via: 'get'
get 'addfriend', to: 'friendships#addfriend'
post 'addfriend', to: 'friendships#addfriend'
get 'addcompany', to: 'friendships#addcompany'
post 'addcompany', to: 'friendships#addcompany'
get 'accept', to: 'friendships#accept'
get 'decline', to: 'friendships#decline'
get 'network', to: 'friendships#index'
get 'privatechat', to: 'messages#privatechat'
get 'storemsg', to: 'messages#storemsg'
get 'employee_list', to: 'shopping_lists#index'
get 'flagged', to: 'postings#flagged'
get 'people', to: 'postings#people'
get 'candidate', to: 'postings#candidate'
end
文件中可能存在一些随机和不必要的行。在过去的两个小时里,我一直在这里添加东西并带走它们。我没有运气。我也看过这些非常相似的帖子。任何人都可以帮助我吗?
Rails 4 + Devise: Invalid route name, already in use
When I use rspec: Invalid route name, already in use: 'root' (ArgumentError)
Invalid route name, already in use: 'admin_root' (ArgumentError) - Failed ActiveAdmin install
以下是静态页面控制器
class StaticPagesController < ApplicationController
def home
@user = current_user
if user_signed_in?
redirect_to profile_path(@user)
end
end
end