Rails Uninitialized Constants :: Generators (NameError)

I am updating the generator code that I wrote, but still worked fine.

When I just rue the team

bundle exec rails g

I get the following error

/Users/mpierc200/projects/prototype_conflux/vendor/gems/itrc_client_files_generator-1.0.13/lib/itrc_client_files_generator.rb:6:in `<top (required)>':
uninitialized constant Rails::Generators (NameError)

Insult line

class ItrcClientFilesGenerator < Rails::Generators::Base

My version of Rails

Rails 3.1.9

ruby version

ruby 1.9.3p194
+5
source share
1 answer

It looks like the Rails generator modules were pulled out and not loaded automatically at some point during the development of Rails 3. This is probably for good reason.

You must include them in custom generators:

require 'rails/generators'

class ItrcClientFilesGenerator < Rails::Generators::Base
  # Fancy generator code here
end
+9
source

All Articles