我在routes.db文件中有这段代码:
resources :users do
member do
get :following, :followers
end
end
我收到错误:
can't use member outside resource(s) scope (ArgumentError)
我该如何解决这个问题?
更新:这是我的routes.db文件的所有代码:
SampleApp::Application.routes.draw do
get "sessions/new"
resources :users
member do
get :following, :followers
end
resources :sessions, :only => [:new, :create, :destroy]
resources :microposts, :only => [:create, :destroy]
resources :relationships, :only => [:create, :destroy]
match '/signup', :to => 'users#new'
match '/signin', :to => 'sessions#new'
match '/signout', :to => 'sessions#destroy'
match '/contact', :to => 'pages#contact'
match '/about', :to => 'pages#about'
match '/help', :to => 'pages#help'
root :to => 'pages#home'
答案 0 :(得分:7)
在您的代码中,您有以下内容:
resources :users
member do
get :following, :followers
end
这意味着您缺少资源声明的do语句和结束语句,请将其更改为:
resources :users do
member do
get :following, :followers
end
end
此外,您缺少Application.routes.draw do语句的最终结尾。