Topic: Control Panels and large number of contained models

How do you like to structure the logic behind control panels -- ie a view that exposes CRUD+extras(order up/down/etc) for a wide range of interacting models.  Typically speaking you'd have lots of "somethings" -- "events" or "trips" or whatever -- that have lots of pieces to configure and you want to have most of the operations reachable in a small number of clicks.  All of these component models typically "belong_to" the master element, so you'll have to be passing around/sessioning the container's id.

Do you "just" create all the seperate controllers for each model and then have tons of url_for(:controller=>, ....), and then have all the actions redirect back to the main panel?  Do you fold all the actions for the cotnained entities into the "master" controller so you simple actions/redirects?  Other options that you're happy with?

My RoR journey  -- thoughts on learning RoR and lessons learned in applying TDD and agile practices.

Re: Control Panels and large number of contained models

Another option I've been considering is to "steal" back the action dispatching from Rails.  For control panel type pages -- where lots of "simple" actions redirect back to the same index page how about an approach like:
all requests use the "control-panel" or similar name action, the control-panel action does a self.send(:subaction) off of a form parameter to handle the request, while finishing with the standard control-panel redisplay.

This way you can avoid the each request = two requests pattern with the direct handlers, but still have urls that make sense for the current location.

My RoR journey  -- thoughts on learning RoR and lessons learned in applying TDD and agile practices.

Re: Control Panels and large number of contained models

Another method, which I don't think is better, is to remove the part_id column from the billables table and just have the serial_number_id column. You can then retrieve the part through the serial_numbers table. For the parts which do not have serial numbers, you would just enter a null value into the serial_numbers table with the associated part_id. That wouldn't eliminate those null values though and is messier than the other solutions IMO.


modern kitchens

Last edited by andrewmikel522 (2010-07-02 09:42:17)