Reputation: 1549
I created a mountable Engine in Rails 4. I am testing it with a dummy test application.
I created my install generator in
'lib/myenginename/install/install_generator.rb':
require 'rails/generators/active_record'
require 'rails/generators/migration'
module Myengine
module Generators
class MyengineGenerator < Rails::Generators::Base
desc "Installs mygem and generates the necessary migrations"
source_root File.expand_path("../templates", __FILE__)
def create_migrations
migration_template 'migrations/m1.rb', 'db/migrate/m1.rb'
end
end
end
end
But when I run
rails g myengine:install
it shows error:
Could not find generator 'myengine:install'. Maybe you meant ...
How to make generator for engine work?
Upvotes: 0
Views: 706
Reputation: 1171
The generator should be in lib/generators/myenginename/
. Read up on http://edgeguides.rubyonrails.org/generators.html#creating-generators-with-generators
Upvotes: 0
Reputation: 1549
generator should be placed in file
lib/generators/myenginename/install_generator.rb
Upvotes: 1