Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uninitialized constant Rails::Generators (NameError)

I'm updating the code for a generator that I wrote, but has been working fine until now.

When I simply rue the command

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)

The offending line is

class ItrcClientFilesGenerator < Rails::Generators::Base

My Rails version is

Rails 3.1.9

ruby version is

ruby 1.9.3p194
like image 581
Marlin Pierce Avatar asked Feb 14 '13 20:02

Marlin Pierce


1 Answers

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

You have to include them in custom generators:

require 'rails/generators'

class ItrcClientFilesGenerator < Rails::Generators::Base
  # Fancy generator code here
end
like image 185
d_ethier Avatar answered Oct 12 '22 14:10

d_ethier