Application templates in Ruby on Rails

8 May 2009, by Michael Cindrić

Here is the latest application template we have put together. It removes all the usual items and adds the base gems that we use for all our applications. It also creates the files needed for deployment and runs "Capify" on the project, plus a few other things such as sass etc.

# Remove unnecessary Rails files
run 'rm README'
run 'rm public/index.html'
run 'rm public/favicon.ico'
run 'rm public/images/rails.png'
run 'rm -f public/javascripts/*'

# Download JQuery
run "curl -s -L > public/javascripts/jquery.js"
run "curl -s -L > public/javascripts/jquery.form.js"

#Configure required gems
gem "haml", :version => "2.0.4"
gem 'thoughtbot-shoulda', :lib => 'shoulda', :source => ''
gem "thoughtbot-factory_girl", :lib => "factory_girl", :source => ""

#Create Sass directory
run 'mkdir public/stylesheets/sass'

#Capify and create production environment.rb
run 'mkdir config/deploy'
run 'touch config/deploy/production.rb'

#Add UAT environment and settings
file 'config/environments/uat.rb', <<-CODE
# Settings specified here will take precedence over those in config/environment.rb

# Code is not reloaded between requests. Server needs to be restarted.
config.cache_classes = true

# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true

# Show full error reports and disable caching
config.action_controller.consider_all_requests_local = false
config.action_controller.perform_caching             = true
config.action_view.cache_template_loading            = true

# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false

#Create gitignore file and setup base ignores
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore"
file '.gitignore', <<-FILE

# Set up git repository
git :init
git :add => '.'
git :commit => "-a -m 'Initial commit'"

# Success!
puts "SUCCESS!"

Cookies help us deliver our services. By using our services, you agree to our use of cookies.