I\'m making a custom generator that generates a new rails app, and I do it like this
require \'thor\'
require \'rails/generators/rails/app/app_generator\'
c
The source_paths method doesn't work when using AppBuilder. (which is another option to using rails templates). I have a files directory next to the app_builder.rb file that this class is in. I have this working, though it seems there should still be a more elegant way.
tree .
|-- app_builder.rb
|-- files
`-- Gemfile
class AppBuilder < Rails::AppBuilder
def initialize generator
super generator
path = File.expand_path( File.join( '..', File.dirname( __FILE__ )) )
source_paths << path
end
def gemfile
copy_file 'files/Gemfile', 'Gemfile'
end
and then on the console:
rails new my_app -b path_to_app_builder.rb
The dots are required since the ruby file 'app_builder.rb' is slurped up and eval'd after the rails new command changes into the new app directory (I think).