I have a simple rails install generator for an engine I'm making:
module Bouncer
module Generators
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path("../../templates", __FILE__)
desc "Copies locale file and migrations to your application."
def copy_locale
copy_file "../../../config/locales/en.yml", "config/locales/bouncer.en.yml"
end
def copy_migrations
# I would like to run "rake bouncer_engine:install:migrations" right here
# rather than copy_file "../../../db/migrate/blah.rb", "db/migrate/blah.rb"
end
end
end
end
When a user runs rails g bouncer:install
, a locale file is copied into their app. I also want to copy in my migrations, but rather than use copy_file
method, I was hoping I could just run rake bouncer_engine:install:migrations
inside the generator, like I would do from the command line. How can I do this?