Reputation: 11929
I have next resources
resources :countries do
resources :cities
end
resources :cities do
resources :streets
end
it generates next routes
GET /countries/:country_id/cities(.:format) cities#index
POST /countries/:country_id/cities(.:format) cities#create
new_country_city GET /countries/:country_id/cities/new(.:format) cities#new
edit_country_city GET /countries/:country_id/cities/:id/edit(.:format) cities#edit
GET /countries/:country_id/cities/:id(.:format) cities#show
PUT /countries/:country_id/cities/:id(.:format) cities#update
DELETE /countries/:country_id/cities/:id(.:format) cities#destroy
......
cities GET /cities(.:format) cities#index
POST /cities(.:format) cities#create
new_city GET /cities/new(.:format) cities#new
edit_city GET /cities/:id/edit(.:format) cities#edit
city GET /cities/:id(.:format) cities#show
PUT /cities/:id(.:format) cities#update
DELETE /cities/:id(.:format) cities#destroy
I dont want access to cities can be without country id but also I don't want to use 3-levels nested resources, so I can change routes like next
resources :countries do
resources :cities
end
resources :cities, :except => [:index, :destroy, :edit, :show, :create, :new, :update] do
resources :streets
end
Is there some kind of shortcut to disable all action instead of write all default actions at :except option ????
Upvotes: 7
Views: 2403
Reputation: 4156
You can follow this routes
resources :topics do resources :solutions end resources :solutions, only: [] do resources :reviews, except: [:show, :index] end
Upvotes: 1