SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: restful design

  1. #1
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    restful design

    Hello
    I'm trying to follow RESTful design on the application I'm working on right now. And I have a doubt so I would like to know what you guys think about it.


    I have 2 models: project and task,where a project has many tasks.

    When I create a project I would like to define all the tasks for that project.

    My question is where I have to put this action: when I create a project, basically I create several tasks so it should be in project controller or task controller? I guess it is better if it is a project action. So I will have a create action for project but not for task (it is meaningless to create a task if not related to a project).

    THANK YOU
    Alla prossima ...

  2. #2
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,345
    Mentioned
    192 Post(s)
    Tagged
    5 Thread(s)
    As a fellow "beginner", I have read the wisdom that each action should call a single class.
    So, your tasks should be constructed in methods of a project class.
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Git is for EVERYONE
    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains

  3. #3
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for your reply
    Alla prossima ...

  4. #4
    SitePoint Member
    Join Date
    Jun 2006
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why not have the create method in the project controller accept a task list if provided, but not complain if one isn't available. I think the project controller should accept the tasks, but you should also be able to access them in the nestled route

    Code:
    map.resources :projects, :has_many => :tasks


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
  •