Nested resource and restricting the Routes Created :only and :except
Asked Answered
M

1

12

Good day all,

Can someone kindly assist me with nested resources and its best practice.

I would like to restrict my :events route to only :show and :index, is this the correct way of doing it?

resources :events do
    resources :registrations, :except => [:index]
end

resources :events, :only => [:index, :show]

Is this the best way or the way more Rubyist would handle such thing? I've added two lines of resources :events or is there a way to combine it all in 1 block?

Thanks in advance.

Mezzo answered 2/11, 2012 at 8:34 Comment(0)
F
21

Yes. You can combine it in one block like:

resources :events, only: [:index, :show] do
    resources :registrations, except: :index
end
Farce answered 2/11, 2012 at 8:45 Comment(1)
Sergey, you sir, are one lovely person. Thank you so much.Mezzo

© 2022 - 2024 — McMap. All rights reserved.