When you want to override a generator template (without replacing the generator itself), in Rails 3 you can just drop files in appropriately named places in lib/templates and Ra
I have the same problem using rails 4.1.5. And here is assembled puzzle solution.
First of all create Railtie in your gem like this. Keep in mind config.generators is deprecated and thalespf`s answer.
module SomeGem
class Railtie < Rails::Railtie
config.app_generators do |g|
g.templates.unshift File::expand_path('../../templates', __FILE__)
end
end
end
Works like a charm!
UPD. I have tried to create a gem with templates only and use it within Rails::Engine. But it requires this:
# lib/your_engine/engine.rb
require 'your_gem_with_generator_templates' # Loads Railtie