Forum: Ruby on Rails inflection issue

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fe42793e924c920c690440497807164b?d=identicon&s=25 Abhishek Srivastava (Guest)
on 2007-05-25 09:22
(Received via mailing list)
Hi all,

I have a table called lenses for which i created the following
inflection
rule in environment.rb to support pluralization of lens.

Inflector.inflections do |inflect|
  inflect.plural(/(lens)$/i, '\1es')
end

Next I generated a scaffold for it

ruby script\generate scaffold admin::lens

But when I access the list view in browser I am getting the following
error

NameError in Admin/lensesController#index

uninitialized constant Lense

RAILS_ROOT: ./script/../config/..
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:266:in
`load_missing_constant'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:452:in
`const_missing'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:464:in
`const_missing'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/inflector.rb:250:in
`constantize'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/core_ext/string/inflections.rb:148:in
`constantize'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/pagination.rb:195:in
`paginator_and_collection_for'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/pagination.rb:130:in
`paginate'
#{RAILS_ROOT}/app/controllers/admin/lenses_controller.rb:12:in `list'
#{RAILS_ROOT}/app/controllers/admin/lenses_controller.rb:3:in `index'

Can someone suggest a fix for this? What am I doing wrong?

Regards,
Abhi
Fe42793e924c920c690440497807164b?d=identicon&s=25 Abhishek Srivastava (Guest)
on 2007-05-25 10:19
(Received via mailing list)
Ah my bad.

changing it to this

Inflector.inflections do |inflect|
  inflect.irregular 'lens', 'lenses'
end

and restarting the application, fixed it.

Regards,
Abhi

----- Original Message -----
From: "Abhishek Srivastava" <abhi_sri@gmx.net>
To: <rubyonrails-talk@googlegroups.com>
Sent: Friday, May 25, 2007 4:05 PM
Subject: [Rails] inflection issue
This topic is locked and can not be replied to.