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.

Scaffolding with name that ends in "ie" does not create or edit correctly.

#5602

I ran across this problem by using straight out of the box scaffolding.

rails generate scaffold Lie title:string etc...

This will produce the correct scaffolding but any attempts to create or edit Lie objects results in Null database inserts. This is all again, with straight out of the box scaffolding.

SQL (0.5ms) INSERT INTO "lies" ("created_at", "description", "title", "updated_at", "source", "video") VALUES ('2010-09-09 21:45:29.951629', NULL, NULL, '2010-09-09 21:45:29.951629', NULL, NULL)
Redirected to http://localhost:3000/lies/1
Completed 302 Found in 72ms

I tried the same thing with other scaffold names in different rails 3.0 environments and still get the same error. I think it has something to do with the way rails generates the scaffolding names and creates the object @ly throughout the code instead of @lie.

You can get the same problem with any other word that ends in "ie" Calorie for example.
rails generate scaffold Calorie does not work either.

Reported by chrisopeterson · September 10th, 2010 @ 12:40 AM

State: resolved
Milestone: 3.x
Assigned to: Neeraj Singh Neeraj Singh
Importance: Low

Activity

  1. Neeraj Singh
    Neeraj Singh
    • Importance changed from to Low

    I am able to create

    rails g scaffold Calorie name:string type:string
    

    And then I am able to hit both

    http://localhost:3000/calories

    http://localhost:3000/calories/1

    I am using rails edge.

    September 10th, 2010 @ 01:08 AM

  2. chrisopeterson
    chrisopeterson

    I can create the scaffolding fine.

    Creating and editing records with the scaffold only inserts null values. I have gotten the same results in different dev environments.

    Ruby 1.8.7 - Rails 3.0.0

    September 10th, 2010 @ 03:39 AM

  3. Neeraj Singh
    Neeraj Singh
    • Milestone set to 3.x
    • State changed from new to open

    September 10th, 2010 @ 10:47 AM

  4. Neeraj Singh
    Neeraj Singh
    • Assigned user set to Neeraj Singh

    September 10th, 2010 @ 11:18 AM

  5. Tim Shaffer
    Tim Shaffer

    I just ran into this same problem. I was able to work around it by adding an inflection:

    inflect.irregular 'Lie', 'Lies'
    

    September 10th, 2010 @ 01:06 PM

  6. Rohit Arondekar
    Rohit Arondekar

    The inflector is used to determine the table names. But the inflector isn't perfect. This certainly looks like one of those cases where the inflector doesn't know how to get the plural. In such cases you need to add an inflection in the config/initializers/inflections.rb as mentioned above.

    September 10th, 2010 @ 01:17 PM

  7. Neeraj Singh
    Neeraj Singh
    • State changed from open to resolved

    As others have pointed out adding following line solves the problem.

    ActiveSupport::Inflector.inflections do |inflect|
      inflect.irregular 'Calory', 'Calories'
    end
    

    September 10th, 2010 @ 01:34 PM