Reputation: 12092
I have a controller named foo
, controller and model named bar
. foo
is just a controller, no model. With foo
, I have a route: /foo
. In the routes I have:
resources :bar
I need something like
/foo/bar/ # new, edit, create, update etc
I can do this with:
resource :foo do
resources :bar
end
Doing so will end up having dashboard create, update etc
and I dont want all those routes.
Is there a simple way, without the unnecessary routes, to have
/foo/bar/new
/foo/bar/edit
# with all methods: post, patch etc?
Upvotes: 0
Views: 51
Reputation: 13115
As outlined in the official guides, You can use only
and except
as options to restrict the actions for which routes are to be generated:
resource :foo, only: [:index] do # exception/inclusion before the do block
resources :bars
end
Upvotes: 2
Reputation: 156
Hope this will work for you ..
Please refer Shallow Nesting section of below url
http://guides.rubyonrails.org/routing.html
Upvotes: 0