I have this code in my routes.db file:
resources :users do
member do
get :following, :followers
end
end
and I get the error:
can't use member outside resource(s) scope (ArgumentError)
How do I fix this?
UPDATE: here’s all the code to my routes.db file:
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'
In your code you have the following:
which means you are missing a do statement and an end statement for your resources declaration, change it to this:
Also, you are missing a final end for the Application.routes.draw do statement.