Reputation: 10939
I have created my own scaffold generator, now it's sitting in my ~/.rails/generator/scaffold directory. How can I make a gem in order to use my generator along other machines I'm using, without the need of copying the ~/.rails folder on every box ? I will push later the gem on Github
Upvotes: 2
Views: 373
Reputation: 23450
From the documentation:
For a RubyGem, put your generator class and templates in the lib directory. For a Rails plugin, make a generators directory at the root of your plugin.
However that's a little vague.
From the Rails::Generator::Lookup source:
Rails application. If RAILS_ROOT is defined we know we're generating in the context of a Rails application, so search RAILS_ROOT/generators.
Look in plugins, either for generators/ or rails_generators/ directories within each plugin
User home directory. Search ~/.rails/generators.
RubyGems. Search for gems named *_generator, and look for generators within any RubyGem's /rails_generators/_generator.rb file.
Builtins. Model, controller, mailer, scaffold, and so on.
A single generator gem should be structured like this:
Gems that contains multiple generators should be structured like this:
Upvotes: 1