SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Guru Skyblaze's Avatar
    Join Date
    Jul 2005
    Location
    Italy
    Posts
    734
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Controller's class names singular or plural?

    Again on rails pluralization :P

    We know that through conventions rails uses, we have to name database tables in plural and the corresponding active record class in the singualr form of the same used term....and this is to make the defaults work. Controller's class names don't have this "constraint" so we can name controllers how we like it.
    What is the best anyway?
    If i have a User model and a corresponding controller with CRUD operations on it, how will you call that controller? User or Users?
    I saw both forms in various places and also in sitepoint's book it is named StoryController and not StoriesController.

  2. #2
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    UsersController is more common.

  3. #3
    SitePoint Guru Skyblaze's Avatar
    Join Date
    Jul 2005
    Location
    Italy
    Posts
    734
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Fenrir2 View Post
    UsersController is more common.
    ok but is there a standard solution?

  4. #4
    SitePoint Addict
    Join Date
    Jan 2006
    Posts
    268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is standard to have it singular. UserController, BlogController, etc..
    After taking a quick look from some of the screen casts on the RoR site, that is their preferred way as well
    If you give someone a program,
    you will frustrate them for a day;
    if you teach them how to program,
    you will frustrate them for a lifetime.

  5. #5
    SitePoint Guru Skyblaze's Avatar
    Join Date
    Jul 2005
    Location
    Italy
    Posts
    734
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pjleonhardt View Post
    It is standard to have it singular. UserController, BlogController, etc..
    After taking a quick look from some of the screen casts on the RoR site, that is their preferred way as well
    yes i saw that too

  6. #6
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That is not true. Rails' generators will in fact generate singular models and plural controllers.

  7. #7
    SitePoint Guru Skyblaze's Avatar
    Join Date
    Jul 2005
    Location
    Italy
    Posts
    734
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Fenrir2 View Post
    That is not true. Rails' generators will in fact generate singular models and plural controllers.
    ok but it is true that in those rubyonrails.com screencasts it is in the singular form I think the singular form is better to explain the fact that for example a User controller is a controller for "User management".

  8. #8
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are doing the resource routing, singular will lead you to /book giving you a list of all books. For all the shortcomings of /books/1, /book for all books makes zero sense.
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?


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
  •