Reputation: 16629
I'm trying to write a Ruby gem (with Rails 3.2.13), I have created a generator to do a file copy.
Following is my generator code
#<mygemname>/lib/generators/mygemname/mygemname_generator.rb
require 'rails/generators'
require 'rails/generators/migration'
module Mygemname
module Generators
class ConfigGenerator < Rails::Generators::Base
p "testing generator"
end
end
end
then I go to the test app in my <mygemname>/spec/dummy
(I use Rspec for testing), so from my dummy app, when I run
rails g I get
Mygemname:
mygemname:config
but when I run rails g endless:config
, I get
Could not find generator endless:config.
but when I run rails g endless
, I get the correct result. But I would like to have the command as rails g endless:config
, how can I do that?
Upvotes: 1
Views: 1166
Reputation: 5847
Try renaming the file: /lib/generators/mygemname/config_generator.rb
And structure config_generator.rb
a bit differently:
class Mygemname
class ConfigGenerator < Rails::Generators::Base
p "testing generator"
end
end
Upvotes: 4