Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a plural/singular reference list for Rails?

Ruby on Rails has many different generators and other such things. In my experience, the naming is hardly ever obvious though for if you should use a singular or plural name.

For instance for the Controller generator you are suppose to use plural

$ rails generate controller Users new

But for Models you are suppose to use singular(for all names)

$ rails generate model User name:string email:string

Is there a thorough reference guide to which generators and such are using singular names and which ones are plural names?

like image 771
Earlz Avatar asked Sep 15 '10 22:09

Earlz


1 Answers

You've pretty much got it.

Think of a model as controlling a single thing, so it's singular, and a controller controls a group of things, so it's plural. Scaffolds center around a model, so that's singular just like the model.

Views and helpers are related to the controller, so they're plural. Migrations don't care.

When in doubt, pass --pretend to the generator and see what it will do.

like image 57
Robert Speicher Avatar answered Oct 06 '22 05:10

Robert Speicher