Search code examples
ruby-on-railspluralize

Why does Rails use plurals for new and create?


I understand why a Rails index method would use the plural form of a resource - we're showing all projects, for example.

And I understand why the show method would use the singular form - we only want to see one project, with a particular ID.

But I don't understand why new and create would use the plural. Is there a way to create more than one project at a time? Is there some other reasoning for using the plural here that someone could explain?


Solution

  • New and Create aren't plural, in the way I think about REST. Instead, I think about it like:

    whatever.com is your base domain, and whatever.com/books means that you have a collection of resources each named book. The collection itself is named books.

    So, when you want to create a new book, you are asking the collection for the information needed to create a new book. This becomes /books/new

    When you actually create the book, you are posting information to /books. The HTTP verb is POST, so when you POST to your collection, you execute the create action.

    This looks like a good starting point on REST.