Actually, I'm really enjoying the 'modularity' discussion... but I'd like to get out of this trench I'm in, so:
I'm migrating a project from one codebase to another to clean up a lot of accumulated cruft, shift to a new presentation layer, etc.
One of the relationships is the canonical User has_many Order, which I have expressed as nested resources in routes.rb:
resources :users do
resources :orders
end
and so I have the expected named route user_orders_path(@user). It works just fine if the user has orders, but if the user has no orders, trying to render the route gives the following error:
ActionController::RoutingError (No route matches {:controller=>"orders",
:user_id=>#<User id: 472, account_id: nil, first_name: "Denis", last_name:
"Haskin", ...etc... , last_sign_in_ip: "127.0.0.1">})
I'm sore of at a loss to explain (and fix) this, and I was hoping this might ring a bell with someone. I tested this in a new empty project and of course it works fine. I guess the next thing I'll try is to strip down as much as I can about these models and the controller, and start adding pieces back until the error recurs. Because I'm migrating over existing code, it's very difficult to isolate this to a small piece of example code.
(At the risk of possibly confusing the issue, I have started using Ryan Bates' cancan[1] in this project and I'm a little suspicious that it might be playing a role here, but I did strip it out and test without it, with no change in this incorrect behavior.)
Thanks for any help, suggestions on how to further investigate, etc (yes, I've also asked on StackOverflow)...
--