[Nitro] Modelling controllers strategies
George Moschovitis
george.moschovitis at gmail.com
Tue Aug 23 02:48:13 EDT 2005
I would suggest to go with separate controllers for 'important'
objects. You can reuse the same layout by defining a common Page
element like it is done in spark. Check out the file src/skin.rb.
A better example of nitro will be released real soon now.
regards,
George.
On 8/22/05, Alan Garrison <alang at cronosys.com> wrote:
> Hi, in my rare pockets of spare time I've been experimenting with a
> designing
> a small CRM application using Nitro. (See www.SugarCRM.com for what I'm
> modelling the UI after, and if you are in a puking mood, download their
> open
> source zip and take a peek). I started by looking at Spark and got just
> some very basic stuff running so far. What I've run into is some confusion
> on how the controller class should behave for what I'm trying to do. Spark
> is simple in that it (basically) deals with just one Og object (WikiPage).
> What I'm trying to do deals with (potentially) numerous business logic
> objects (Contacts, Accounts, Projects, Leads, etc). I've got basic Og
> objects for these, and that in itself isn't a problem.
>
> For example, I envision talking to the controller like so:
>
> /view/Home -- Display homepage (index default page)
> /view/Contacts -- View Browse/Search/Panel for Contacts
> /view/Accounts -- View Browse/Search/Panel for Accounts
> (Or perhaps have a "/search/Contacts", use different controller call)
> /view/Contacts/239030294083820 -- View this contact's details
> /edit/Contacts/239030294083820 -- Edit this contact's details
>
> All "screens" will have some common header and footer templating logic,
> but the main guts of the page will behave based on which object type
> you are loading/editing. So my initial question is "should I try to
> have one controller try to handle everything?" Like so:
>
> -----8<-----
> class MyController < Nitro::Controller
> def view(screen = 'Home', oid = '')
> @someobj = MyBaseClass.find_by_oid(oid)
> ### now try to determine what to do based on the screen
> if screen == 'Contacts' # do something...
> elsif screen == 'Accounts' # do something...
> end
> ### and so on...
> end
> -----8<-----
>
> Or would I be better off having a controller per object type (even though
> I'm not quite sure how to handle the common header/footer stuff)?
>
> -----8<-----
> class ContactsController < Nitro::Controller
> def view(oid = '')
> # We know it's a contact already
> @somecontact = Contact.find_by_oid(oid)
> end
> ### and so on...
> end
>
> ### probably in a separate file:
> class AccountsController < Nitro::Controller
> def view(oid = '')
> # We know it's an account already
> @someaccount = Account.find_by_oid(oid)
> end
> ### and so on...
> end
> -----8<-----
>
> Years of mod_php style programming is making my grokking of the MVC
> paradigm a little bit challenging. :) Any suggestions to the above, or
> maybe
> there's a better way that I'm missing?
>
>
> --
> Alan Garrison
> Cronosys, LLC <http://www.cronosys.com>
> Phone: 216-221-4600 ext 308
>
>
> _______________________________________________
> Nitro-general mailing list
> Nitro-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/nitro-general
>
--
http://www.gmosx.com
http://www.navel.gr
http://www.nitrohq.com
More information about the Nitro-general
mailing list