#148 App Templates in Rails 2.3
Feb 09, 2009 | 11 minutes | Rails 2.3
In Rails 2.3 you can provide a template when generating a new Rails application. See how in this episode.
- Download:
- source codeProject Files in Zip (1.56 KB)
- mp4Full Size H.264 Video (19.7 MB)
- m4vSmaller H.264 Video (12.6 MB)
- webmFull Size VP8 Video (33.2 MB)
- ogvFull Size Theora Video (27 MB)
Resources
- Rails 2.3 Release Notes
- Rails templates
- Rails Template Examples
- ryanb's rails-templates
- Full Episode Source Code
bash
sudo gem install rails --source http://gems.rubyonrails.org
rails -v
rails store -m base_template.rb
rails store -m auth_template.rb
sudo gem install rails --source http://gems.rubyonrails.org rails -v rails store -m base_template.rb rails store -m auth_template.rb
base_template.rb
run "echo TODO > README"
generate :nifty_layout
gem 'RedCloth', :lib => 'redcloth'
gem 'mislav-will_paginate', :lib => 'will_paginate', :source => 'http://gems.github.com'
rake "gems:install"
if yes?("Do you want to use RSpec?")
plugin "rspec", :git => "git://github.com/dchelimsky/rspec.git"
plugin "rspec-rails", :git => "git://github.com/dchelimsky/rspec-rails.git"
generate :rspec
end
git :init
file ".gitignore", <<-END
.DS_Store
log/*.log
tmp/**/*
config/database.yml
db/*.sqlite3
END
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore"
run "cp config/database.yml config/example_database.yml"
git :add => ".", :commit => "-m 'initial commit'"
run "echo TODO > README" generate :nifty_layout gem 'RedCloth', :lib => 'redcloth' gem 'mislav-will_paginate', :lib => 'will_paginate', :source => 'http://gems.github.com' rake "gems:install" if yes?("Do you want to use RSpec?") plugin "rspec", :git => "git://github.com/dchelimsky/rspec.git" plugin "rspec-rails", :git => "git://github.com/dchelimsky/rspec-rails.git" generate :rspec end git :init file ".gitignore", <<-END .DS_Store log/*.log tmp/**/* config/database.yml db/*.sqlite3 END run "touch tmp/.gitignore log/.gitignore vendor/.gitignore" run "cp config/database.yml config/example_database.yml" git :add => ".", :commit => "-m 'initial commit'"
auth_template.rb
load_template "/Users/rbates/code/base_template.rb"
name = ask("What do you want a user to be called?")
generate :nifty_authentication, name
rake "db:migrate"
git :add => ".", :commit => "-m 'adding authentication'"
generate :controller, "welcome index"
route "map.root :controller => 'welcome'"
git :rm => "public/index.html"
git :add => ".", :commit => "-m 'adding welcome controller'"
load_template "/Users/rbates/code/base_template.rb" name = ask("What do you want a user to be called?") generate :nifty_authentication, name rake "db:migrate" git :add => ".", :commit => "-m 'adding authentication'" generate :controller, "welcome index" route "map.root :controller => 'welcome'" git :rm => "public/index.html" git :add => ".", :commit => "-m 'adding welcome controller'"

