Domanda

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.

È stato utile?

Soluzione

Yes. You can combine it in one block like:

resources :events, only: [:index, :show] do
    resources :registrations, except: :index
end
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top