Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Correct routing for nested resources


  • Please log in to reply
No replies to this topic

#1 malcoauri

malcoauri

    Passenger

  • Members
  • 2 posts

Posted 08 October 2013 - 10:19 AM

Hi! There are 'Type' model and 'Place' model. 'Place' describes places of entertainment: cafes, clubs, etc. Cafes, clubs, etc are 'Type'. I need to create routing to take all places by type:

resources :types do
  resources :places
end

It's good, now I can take places in 'index' action of PlacesController with params[:type_id] (for example, 'types/1/places'). But I also need to get list of ALL places independently of their types (just Place.all). But 'index' action of PlacesController returns places by their type_id, it can't do 2 things in the same time. How can I solve this problem?  






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users