NameError: uninitialized constant Inflector

96 views
Skip to first unread message

dschruth

unread,
Sep 19, 2008, 9:13:53 PM9/19/08
to Ruby on Rails: Talk
I follwed the example here:
http://dekstop.de/weblog/2005/12/rails_inflector_in_ruby_scripts/

#!/usr/bin/ruby
require 'rubygems'
require 'active_support/inflector'
puts Inflector.singularize('inflections')

I loaded it into irb and wrote a killer script both of which worked
perfectly for weeks.

Now when I try and run the script or run these simple example lines of
code it doesn't work anymore. And I can't for the life of me figure
out what I changed to break it! The last line gives me this error:

irb(main):003:0> puts Inflector.singularize('inflections')
NameError: uninitialized constant Inflector
from (irb):3

Does anybody know what might cause this? Is it a new plugin (like
action-mailer) that I installed? Is it a bad environmental
variable?

Thanks,

Dave

Jeffrey L. Taylor

unread,
Sep 20, 2008, 10:22:58 AM9/20/08
to rubyonra...@googlegroups.com
Quoting dschruth <dsch...@gmail.com>:
>
> I follwed the example here:
> http://dekstop.de/weblog/2005/12/rails_inflector_in_ruby_scripts/
>
> #!/usr/bin/ruby
> require 'rubygems'
> require 'active_support/inflector'
> puts Inflector.singularize('inflections')
>
> I loaded it into irb and wrote a killer script both of which worked
> perfectly for weeks.
>
> Now when I try and run the script or run these simple example lines of
> code it doesn't work anymore. And I can't for the life of me figure
> out what I changed to break it! The last line gives me this error:
>
> irb(main):003:0> puts Inflector.singularize('inflections')
> NameError: uninitialized constant Inflector
> from (irb):3
>

Probably you updated Rails to 2.1.1. The above usage is now deprecated and
gives a warning to that effect in Rails. Don't know why no warning in
straight Ruby. Anyway, try

puts ActiveSupport::Inflector.singularize('inflections')

HTH,
Jeffrey

dschruth

unread,
Sep 20, 2008, 6:41:01 PM9/20/08
to Ruby on Rails: Talk
thanks that worked!

On Sep 20, 7:22 am, "Jeffrey L. Taylor" <r...@abluz.dyndns.org> wrote:
Reply all
Reply to author
Forward
0 new messages