Hi all, Suppose I''ve got two resources: "customers" and "bills". Each "bill" belongs to a "customer". It seems clear to me that the routes.rb must contain something like this: map.resources :customers do |customer| customer.resources :bills end So, I could get all the bills for a customer with this URI: ''/ customers/3/bills'' But what if I wanna get ALL the bills (for all customers) using something like: ''/bills''? I guess I''ve got two options: a) Add "map.resources :bills" to the routes.rb file and, in BillsController, check for a customer_id parameter (if it''s not set, I''d list all the bills). b) Add a new controller "all_bills" that I could use only for listing ALL the bills (and maybe adding, editing or destroying bills out of the customer context). What''s the "Rails-way"? Any other idea? Thank you very much in advance. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
both your solutions are ok, i''ve used variations of them in the past, depending mainly on the question how much the index/customer and index/all has different view and controller code. in most cases i would go for the first variant if i can keep it simple enough -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you. I suppose that it''s the logical way. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You could use named route as well. Declaring map.resources :bills gives you too many methods that you don''t need. On Dec 15, 2007 10:56 AM, Imobach González Sosa <imobachgs-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Thank you. I suppose that it''s the logical way. > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---