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.

Inflection error not corrected with inflection when recognize resource scaffold routes

#4926

Generated a resource scaffold for "wave"

It generated the wrong inflection "wafe" for singular instead of "wave"

                   GET    /waves(.:format)                           {:controller=>"waves", :action=>"index"}
             waves POST   /waves(.:format)                           {:controller=>"waves", :action=>"create"}
          new_wafe GET    /waves/new(.:format)                       {:controller=>"waves", :action=>"new"}
                   GET    /waves/:id(.:format)                       {:controller=>"waves", :action=>"show"}
                   PUT    /waves/:id(.:format)                       {:controller=>"waves", :action=>"update"}
              wafe DELETE /waves/:id(.:format)                       {:controller=>"waves", :action=>"destroy"}
         edit_wafe GET    /waves/:id/edit(.:format)                  {:controller=>"waves", :action=>"edit"}

I added a correction to the inflector in environment.rb

ActiveSupport::Inflector.inflections do |inflect|
    inflect.irregular "wave", "waves"
  end

and tested a new app. The routes were generated correctly but weren't recognized

          GET    /waves(.:format)          {:controller=>"waves", :action=>"index"}
    waves POST   /waves(.:format)          {:controller=>"waves", :action=>"create"}
 new_wave GET    /waves/new(.:format)      {:controller=>"waves", :action=>"new"}
          GET    /waves/:id(.:format)      {:controller=>"waves", :action=>"show"}
          PUT    /waves/:id(.:format)      {:controller=>"waves", :action=>"update"}
     wave DELETE /waves/:id(.:format)      {:controller=>"waves", :action=>"destroy"}
edit_wave GET    /waves/:id/edit(.:format) {:controller=>"waves", :action=>"edit"}

I get the same error when going to /waves (index action) as I did before changing the inflector.

ActionView::Template::Error (undefined local variable or method "new_wave_path" for #<#<Class:0x1043eabc0>:0x1043e8848>):
    22: 
    23: <br />
    24: 
    25: <%= link_to "New Wave", new_wave_path %>
/Users/alanmccann/railsapps/wavetest/app/views/waves/index.html.erb:25:in _render_template_2110420769_2183084200_0

This issue doesn't happen when the inflector works correctly on its own when a new scaffold is generated.

Reported by Alan McCann · June 22nd, 2010 @ 05:11 AM

State: invalid
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Rohit Arondekar
    Rohit Arondekar

    You need to add the correction to config/initializers/inflections.rb. It should work then. Can you please try it out and update this ticket if the issue gets resolved?

    June 22nd, 2010 @ 06:15 AM

  2. Alan McCann
    Alan McCann

    That was it. Works perfectly.
    Thank you.

    June 22nd, 2010 @ 06:29 AM

  3. Rohit Arondekar
    Rohit Arondekar
    • State changed from new to invalid

    Cheers. :)

    June 22nd, 2010 @ 06:30 AM

  4. Ryan Bigg
    Ryan Bigg
    • Tag cleared.

    Automatic cleanup of spam.

    October 11th, 2010 @ 10:55 AM