The problem is that the routes conflict. The way to get the routes
untangled is to use :name_prefix => 'something_' and
possibly :path_prefix => '/something/:some_id'. I wanted to
experiment with this to see what all is necessary, because I've been
facing this in my own application.
The trick, once I got my routes untangled, was to make sure the views
and the controller stays untangled too. If I were in your
application, I'd probably create a:
before_filter :find_category
and then
def find_category
@category = nil
@category = Category.find(params[:category_id]) if
params[:category_id]
end
Then, when you call all the orders_url and order_url(@order), etc. in
your controller and views, you'll put a conditional there, to pass
@category if @category (like @category ? order_url(@category,
@order) : order_url(@order).
Does that make sense?
To summarize, you'll want to create the nested resources
with :name_prefix, and you'll want to know what kind of url you'll be
calling.
If you find a cleaner way to keep your routes untangled in your views
and controllers, please let me know. I'm going to have this
everywhere in an app I'm working on.
David