You can go as deep as you like, nested routes, but keep in mind that just because you can doesn’t mean what you need. The deeper you dig, the more work you create for yourself.
I saw that for each depth level you need to create a base controller that processes the parent parameters, and a subclass that processes the specifics. This tends to reproduce along the lines of:
Customer::BaseController < ApplicationController
CustomerController < CustomerController:: BaseController
Customer::Orders::BaseController < Customer::BaseController
Customer::OrdersController < Customer::Orders::BaseController
Customer::Orders::Items::BaseController < Customer::Orders::BaseController
Customer::Orders::ItemsController < Customer::Orders::Items::BaseController
BaseController in each case handles the loading and interpretation of parameters in a general way, for example:
class Customer::BaseController < ApplicationController
before_filter :load_customer
protected
def load_customer
@customer = Customer.find(params[:customer_id] || params[:id])
rescue ActiveRecord::RecordNotFound
render(:partial => 'customer_not_found', :layout => 'application', :status => :not_found)
end
end
As you can see, it can get a little confused if you draw your application this way. You also get very long routes.
, , , . @order.customer client_id .