SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast Stevenwulf's Avatar
    Join Date
    May 2002
    Location
    Berkeley
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    RoR Design Question

    I'm having some trouble figuring out how to break a project into various
    controllers. Here's my situation. Say I'm building a small web store
    that sells software. Each piece of software will belong to a given
    Vendor.

    Ok, so there are my two models 'Software' and 'Vendor'. I'd like to be
    able to do basic CRUD on both a Vendor and and or a Product. However, I
    want the Vendor to be a sort of Gateway to the Product. So let's say I
    create the basic CRUD actions for the Vendor. If I'm viewing a Vendor's
    info--name, address, url, etc-- that's where I would also see options
    like: 'List Products', 'Create Product'.

    So the real question is should I use one controller or two controllers?

    If I used one controller I would have actions like:
    /admin/vendor/add
    /admin/vendor/list
    /admin/vendor/view
    /admin/vendor/add_product
    /admin/vendor/list_products
    /admin/vendor/view_product

    If I used two controllers:
    /admin/vendor/add
    /admin/vendor/list
    /admin/vendor/view
    /admin/product/add
    /admin/product/list
    /admin/product/view

    Thanks,
    Steven

  2. #2
    SitePoint Zealot
    Join Date
    Nov 2004
    Location
    Yakima WA.
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd go with two controllers for this purpose. Since you will probably end up adding more methods for each controller and if you put it all in one it will get huge.

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2005
    Location
    Murcia, Spain
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    me too. You should still keep the contorl somewhere to crud with individual controllers. You can mix and match things on your view pages as much as you want later. And if you're just starting your design, you might find later on that you actually would like to do it a different way, which would be more difficult if everything was already mixed together.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •