Forum: Ruby on Rails Why default to plural controller in generate scaffold?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
81194a50c0f9bd95d7832a77fdf371bd?d=identicon&s=25 cool_screen_name90001 (Guest)
on 2005-11-15 03:27
(Received via mailing list)
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
24d2f8804e6bb4b7ea6bd11e0a586470?d=identicon&s=25 jeremy (Guest)
on 2005-11-15 04:12
(Received via mailing list)
-----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-----
81194a50c0f9bd95d7832a77fdf371bd?d=identicon&s=25 cool_screen_name90001 (Guest)
on 2005-11-15 04:21
(Received via mailing list)
--- Jeremy Kemper <jeremy@bitsweat.net> 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
http://mail.yahoo.com
230ccd9aa66613ac4515ff5861b4c5af?d=identicon&s=25 gboyer (Guest)
on 2005-11-15 06:09
(Received via mailing list)
On 11/14/05, CSN <cool_screen_name90001@yahoo.com> wrote:
> > form of
> > >
> model. Seems like the default should be to create a
> Yahoo! Mail - PC Magazine Editors' Choice 2005
> http://mail.yahoo.com
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> 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
230ccd9aa66613ac4515ff5861b4c5af?d=identicon&s=25 gboyer (Guest)
on 2005-11-15 06:12
(Received via mailing list)
On 11/14/05, Gabe Boyer <gboyer@gmail.com> 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
5cfd7e9223637ea26c81c2cc3e43799e?d=identicon&s=25 craig (Guest)
on 2005-11-15 10:22
(Received via mailing list)
> 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
230ccd9aa66613ac4515ff5861b4c5af?d=identicon&s=25 gboyer (Guest)
on 2005-11-15 15:47
(Received via mailing list)
On 11/15/05, Craig Webster <craig@xeriom.net> wrote:
> Craig Webster | web: http://xeriom.net/  | Monkey see, monkey do: Okay.
> Xeriom.NET    | tel: +44 (0)131 516 8595 | Monkey top post: Bad monkey.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>

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

Gabe
This topic is locked and can not be replied to.