#148 Custom App Generators (revised)
Feb 03, 2013 | 10 minutes | Tools
Learn how to customize the Rails app generator to fit your preference. This episode shows how to do this using .railsrc file, app templates, app builders, RailsWizard, and AppScrolls.
- Download:
- source code Project Files in Zip (1.26 KB)
- mp4 Full Size H.264 Video (29.9 MB)
- m4v Smaller H.264 Video (12.9 MB)
- webm Full Size VP8 Video (13.1 MB)
- ogv Full Size Theora Video (29.2 MB)
Browse_code
Browse Source Code
Resources
terminal
rails new blog -m app_template.rb rails new blog -b app_builder.rb gem install appscrolls rbenv rehash scrolls list scrolls new blog -s rspec capybara guard
app_template.rb
remove_file "README.rdoc" create_file "README.md", "TODO" gem "rspec-rails", group: [:test, :development] run "bundle install" generate "rspec:install" if yes? "Do you want to generate a root controller?" name = ask("What should it be called?").underscore generate :controller, "#{name} index" route "root to: '#{name}\#index'" remove_file "public/index.html" end git :init append_file ".gitignore", "config/database.yml" run "cp config/database.yml config/example_database.yml" git add: ".", commit: "-m 'initial commit'"
app_builder.rb
class AppBuilder < Rails::AppBuilder def readme create_file "README.md", "TODO" end def test @generator.gem 'rspec-rails', group: [:test, :development] run 'bundle install' generate 'rspec:install' end def leftovers if yes? "Do you want to generate a root controller?" name = ask("What should it be called?").underscore generate :controller, "#{name} index" route "root to: '#{name}\#index'" remove_file "public/index.html" end git :init append_file ".gitignore", "config/database.yml" run "cp config/database.yml config/example_database.yml" git add: ".", commit: "-m 'initial commit'" end end
loading