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.