Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

scaffold problem when using certain words

#6363

Hi,

I found a bug when using scaffold in Rails 3.0.3.

Example:

$ rails new rails3
$ cd rails3 
rails3$ rails g scaffold stadium name:string

This command creates a file like the following...

rails3/app/views/stadia$ less new.html.erb
<h1>New stadium</h1>
<%= render 'form' %>
<%= link_to 'Back', stadias_path %>

link_to helper has "stadias_path". but I think, "stadia_path" is correct.

Please check it.

Reported by Takuya Okamoto · February 2nd, 2011 @ 02:49 PM

State: committed
Milestone: none
Assigned to: Santiago Pastorino Santiago Pastorino
Importance: none

Activity

  1. 2kan
    2kan

    Takuya Okamoto, looks like you're right, gonna dig a bit more and assign a patch if you're correct.

    February 7th, 2011 @ 10:41 PM

  2. 2kan
    2kan
    • Tag set to rails edge, bug, generators, patch
    • Assigned user set to Santiago Pastorino

    Yes, there is a problem that pluralize of a 'stadia' is 'stadias' (really don't know is it correct in english or not), but we know that stadia is correct plural for stadium (but not very popular I think, isn't it?).

    I've attached a patch (some test assigned for 'stadium') where I avoid calling pluralize on already pluralized words and singularize on already singularized for the table_name in the named_base.rb (see patch for more details).

    February 8th, 2011 @ 01:29 AM

  3. Dan Pickett
    Dan Pickett

    statia or stadiums are the correct terms according to answers.com and dictionary.com

    http://wiki.answers.com/Q/What_is_the_plural_of_the_word_stadium
    http://dictionary.reference.com/browse/stadia

    2kan's approach is solid, but there is a deeper problem with the inflector. To avoid the problem in other places I added more omnipotent handling in the inflections so that "weird_string".pluralize.pluralize maintains the proper plural form.

    I also added a test loop for all the double plural test cases

    Otherwise

    "oxen".pluralize.pluralize => "oxens"
    "media".pluralize.pluralize => "medias"
    

    February 8th, 2011 @ 02:49 AM

  4. 2kan
    2kan

    Dan, yes, that's great. I wasn't sure that I can fix it right in the inflector and not sure that there is no more such problems so I've decided just not to call them twice in generators.

    February 8th, 2011 @ 03:25 AM

  5. 2kan
    2kan

    I've tested both patches for 3.0.4 Everything is ok.

    February 16th, 2011 @ 12:12 PM

  6. 2kan
    2kan

    This bug is reproduces for 3.0.4 and both patches fixes the issue.

    February 16th, 2011 @ 12:45 PM

  7. 2kan
    2kan

    Summary: This patches was done agains master and tested against master. Also I've applied them against 3.0.4 (this issue exists there) and tested (everything is ok). And I've applied them against 3.0-stable (this issue exists there) and tested (everything is ok).

    February 16th, 2011 @ 02:32 PM

  8. Repository
    Repository
    • State changed from new to committed

    (from [c6fac7b449ad88a623d99487d2731dddc6555636]) Fixed issue #6363 scaffold problem when using certain words, avoid to pluralized already pluralized names and singularize a single in generators, for example stadia is a valid plural for stadium. But calling pluralize for stadia will return stadias which sematically is not corrent in this case

    [#6363 scaffold problem when using certain words state:committed]

    Signed-off-by: Santiago Pastorino santiago@wyeworks.com
    https://github.com/rails/rails/commit/c6fac7b449ad88a623d99487d2731...

    February 16th, 2011 @ 05:31 PM

  9. Repository
  10. Repository
  11. Repository
    Repository

    (from [149c3d687aba7093c925d8824c610e3639f976bd]) Fixed issue #6363 scaffold problem when using certain words, avoid to pluralized already pluralized names and singularize a single in generators, for example stadia is a valid plural for stadium. But calling pluralize for stadia will return stadias which sematically is not corrent in this case

    [#6363 scaffold problem when using certain words state:committed]

    Signed-off-by: Santiago Pastorino santiago@wyeworks.com
    https://github.com/rails/rails/commit/149c3d687aba7093c925d8824c610...

    February 16th, 2011 @ 05:32 PM