This project is archived and is in readonly mode.

#4926 ✓invalid
Alan McCann

Inflection error not corrected with inflection when recognize resource scaffold routes

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

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.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages