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.

Inflections issue with script/generate scaffold

#2783

I need to add two infections for a single term in order to have Rails behave correctly:

1) inflect.irregular 'factura_condominio', 'facturas_condominio'
2) inflect.irregular 'FacturaCondominio', 'FacturasCondominio'

If I only use (1) then I get:

create  app/controllers/factura_condominios_controller.rb
create  test/functional/factura_condominios_controller_test.rb
create  app/helpers/factura_condominios_helper.rb
create  test/unit/helpers/factura_condominios_helper_test.rb
 route  map.resources :factura_condominios

If I only use (2) then I get

create    test/fixtures/factura_condominios.yml
create    db/migrate/20090608162459_create_factura_condominios.rb

Not only the migration filename is incorrect, but the whole migration is invalid as the migration filename doesn't match its class name (CreateFacturasCondominio). Therefore it fails with this error: "uninitialized constant CreateFacturaCondominios"

Even if I manually fix all the problems the migration, and use set_table_name in the model, I get into trouble further down the road when I try to use the REST helpers. For example, the call to new_factura_condominio_path (written by the scaffolding code) is not recognized.

There is one more thing. script/destroy also fails to remove all the files created by script/generate scaffold.

To work around all this problems, I just have to use both inflections. But having to use both is clearly not the desired behavior.

Reported by Gustavo Delfino · June 8th, 2009 @ 06:17 PM

State: stale
Milestone: 3.x
Assigned to: nobody
Importance: none

Activity

  1. Gustavo Delfino
    Gustavo Delfino

    I forgot to say that this is with Rails 2.3.2

    June 8th, 2009 @ 06:18 PM

  2. Matt Jones
    Matt Jones

    The inflector isn't particularly aware of non-English pluralization rules; it assumes that the last part of the string is what will change. Thus, you need the two different inflections since /factura_condominio$/ (with the underscore) won't match against 'facturacondominio' (the other version, downcased).

    June 8th, 2009 @ 08:56 PM

  3. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  4. Rohit Arondekar
    Rohit Arondekar
    • State changed from new to stale
    • Importance changed from to

    Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.

    October 9th, 2010 @ 04:09 AM

  5. Ryan Bigg
    Ryan Bigg
    • Tag cleared.

    Automatic cleanup of spam.

    October 11th, 2010 @ 10:56 AM