# Why default to plural controller in generate scaffold?

**URL:** <https://www.ruby-forum.com/t/why-default-to-plural-controller-in-generate-scaffold/61810>\
**Category:** Rails\
**Created:** [November 15, 2005, 3:27am UTC](https://www.ruby-forum.com/t/why-default-to-plural-controller-in-generate-scaffold/61810 "2005-11-15T03:27:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cool\_screen\_name900](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@cool\_screen\_name900](https://www.ruby-forum.com/u/cool_screen_name900)\
**Post date:** [November 15, 2005, 3:27am UTC](https://www.ruby-forum.com/t/why-default-to-plural-controller-in-generate-scaffold/61810/1 "2005-11-15T03:27:09Z")

</div>

from ‘generate scaffold’:

“If a controller name is not given, the plural form of  
the model name will be used. The model and controller  
names may be given in CamelCase or under\_score and  
should not be suffixed with ‘Model’ or ‘Controller’.  
Both model and controller names may be prefixed with a  
module like a file path; see the Modules Example for  
usage.”

Isn’t this the complete opposite of the whole  
singularization philosophy? I thought controllers were  
supposed to be singular.

But it doesn’t work anyhow:

> generate scaffold Abc  
> You have a nil object when you didn’t expect it!  
> You might have expected an instance of Array.  
> The error occured while evaluating nil.include?

csn

* * *

Yahoo! FareChase: Search multiple travel sites in one click.  
[http://farechase.yahoo.com](http://farechase.yahoo.com)

---

<div class="post-metadata">

**Author:** ![cool\_screen\_name900](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@cool\_screen\_name900](https://www.ruby-forum.com/u/cool_screen_name900)\
**Post date:** [November 15, 2005, 4:12am UTC](https://www.ruby-forum.com/t/why-default-to-plural-controller-in-generate-scaffold/61810/2 "2005-11-15T04:12:15Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

On Nov 14, 2005, at 6:25 PM, CSN wrote:

> Isn’t this the complete opposite of the whole  
> singularization philosophy? I thought controllers were  
> supposed to be singular.

Not sure about that. Explain?

> But it doesn’t work anyhow:
> 
> > generate scaffold Abc  
> > You have a nil object when you didn’t expect it!  
> > You might have expected an instance of Array.  
> > The error occured while evaluating nil.include?

This bug has been fixed in the next release. Please specify both  
model and controller name:  
script/generate scaffold Abc Abc

jeremy

-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.2 (Darwin)

iD8DBQFDeVHkAQHALep9HFYRAhlHAKDdvBy4dYxrAjrNZBihiKlsHgdq4QCdFQuR  
jq+6qzPF0i3HmT0s1omyddg=  
=Ehvk  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![cool\_screen\_name900](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@cool\_screen\_name900](https://www.ruby-forum.com/u/cool_screen_name900)\
**Post date:** [November 15, 2005, 4:21am UTC](https://www.ruby-forum.com/t/why-default-to-plural-controller-in-generate-scaffold/61810/3 "2005-11-15T04:21:16Z")

</div>

— Jeremy K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > names may be given in CamelCase or under\_score and  
> > were  
> > supposed to be singular.
> 
> Not sure about that. Explain?

Everything I’ve read in Rails states that tables  
should be singularized when creating models and  
controllers, e.g. items table → Item controller, Item  
model. Seems like the default should be to create a  
singular model. Or at least match the inflection of  
the controller.

csn

* * *

Yahoo! Mail - PC Magazine Editors’ Choice 2005

> **[\[object](https://mail.yahoo.com/)**
>
> \[object

---

<div class="post-metadata">

**Author:** ![cool\_screen\_name900](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@cool\_screen\_name900](https://www.ruby-forum.com/u/cool_screen_name900)\
**Post date:** [November 15, 2005, 6:09am UTC](https://www.ruby-forum.com/t/why-default-to-plural-controller-in-generate-scaffold/61810/4 "2005-11-15T06:09:29Z")

</div>

On 11/14/05, CSN [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > form of
> > 
> > >
> 
> model. Seems like the default should be to create a  
> Yahoo! Mail - PC Magazine Editors’ Choice 2005  
> [http://mail.yahoo.com](http://mail.yahoo.com)
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

While it’s true that Rails defaults would lead you to have an items  
table → Item model, I don’t believe I’ve heard anyone apply the same  
convention to controller names. As far as I’ve seen, most people seem  
to use singular/plural controller names interchangeably, depending on  
the specific case, and what they prefer.

Gabe

---

<div class="post-metadata">

**Author:** ![cool\_screen\_name900](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@cool\_screen\_name900](https://www.ruby-forum.com/u/cool_screen_name900)\
**Post date:** [November 15, 2005, 6:12am UTC](https://www.ruby-forum.com/t/why-default-to-plural-controller-in-generate-scaffold/61810/5 "2005-11-15T06:12:30Z")

</div>

On 11/14/05, Gabe B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > > “If a controller name is not given, the plural  
> > > > usage.”  
> > > > controllers, e.g. items table → Item controller, Item
> > 
> > * * *
> 
> convention to controller names. As far as I’ve seen, most people seem  
> to use singular/plural controller names interchangeably, depending on  
> the specific case, and what they prefer.
> 
> Gabe

“Interchangeably” might have been a poor choice of words; that implies  
someone might use both singular and plural forms to refer to the same  
controller. Of course, I meant that someone might use the singular  
form for one controller name (i.e. ItemsController), and the plural  
form for another (i.e. BlogController).

🙂

Gabe

---

<div class="post-metadata">

**Author:** ![cool\_screen\_name900](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@cool\_screen\_name900](https://www.ruby-forum.com/u/cool_screen_name900)\
**Post date:** [November 15, 2005, 10:22am UTC](https://www.ruby-forum.com/t/why-default-to-plural-controller-in-generate-scaffold/61810/6 "2005-11-15T10:22:30Z")

</div>

> Of course, I meant that someone might use the singular  
> form for one controller name (i.e. ItemsController), and the plural  
> form for another (i.e. BlogController).

I prefer the other way around 😉  
Plural = ItemsController  
Singular = BlogController

Craig

---

<div class="post-metadata">

**Author:** ![cool\_screen\_name900](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@cool\_screen\_name900](https://www.ruby-forum.com/u/cool_screen_name900)\
**Post date:** [November 15, 2005, 3:47pm UTC](https://www.ruby-forum.com/t/why-default-to-plural-controller-in-generate-scaffold/61810/7 "2005-11-15T15:47:48Z")

</div>

On 11/15/05, Craig W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Craig W. | web: [http://xeriom.net/](http://xeriom.net/) | Monkey see, monkey do: Okay.  
> [Xeriom.NET](http://Xeriom.NET) | tel: +44 (0)131 516 8595 | Monkey top post: Bad monkey.
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

Hmm. Now that you mention it, I think I like your way better. 🙂

Gabe
