John, I read your post as you had, for example, multiple promotion controllers based on what it was a promotion for.
So your question is how to better organize your code/app/resources so you don't have so many controllers? Each controller generally only one parent object that it is attached to? Since it looks like your making a storefront I would suggest looking at Spree's ERD for inspiration. (http://rails-erd.rubyforge.org/images/ spree.png) To answer your original question about load paths, no gems should be explicitly requiring a file from the app directory. Of course some of them may, but they should rely on the rails magic to find the necessary model (and presumable controller) files if they need them. On May 18, 11:45 am, John W <[email protected]> wrote: > On May 18, 4:08 pm, PsiPro <[email protected]> wrote: > > > Hello, > > > Nested routes are for prettier urls and better leaner controllers. If > > you need to scope the controller based on what it is nested under its > > not DRY code. > > I'm not sure I understand what you mean by not DRY. Here is how my > controller directory looks without namespaces/sub-directories: > > app/controllers/products_controller.rb > app/controllers/discounts_controller.rb > app/controllers/promotions_controller.rb > . > . > app/controllers/expirations_controller.rb > app/controllers/coupons_controller.rb > > apart from products controller, each of the controllers listed manages > a resource with some relation to the Product model. Either it's an > associated model (Coupon) or it's a resource that manipulates Product > in some way (e.g. products/14/expirations/create calls > @prouduct.expire!). Each resource needs to load the associated parent > for things like authorisation, so I think a parent/child setup is > valid. > > previously, 'discount', 'promote', 'expire' etc were all extra actions > in the products controller. They now have their own controllers, but I > have 60+ controllers each handling different resources. As you can > imagine, this is making the controllers directory a little unwieldy > and I'm looking for a way to better organise the controllers to make > them easier to find. In the case of nested resources, grouping by the > name of the parent resource seems like a logical approach. > > How is scoping based on the parent any less DRY than having no scope? -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

