Skip to content
Create a gist now

Instantly share code, notes, and snippets.

davidw rails template
# Originall created by, adapted by David N. Welton -
# rails new APP_NAME -m /path/to/gist/davidwrailstemplate.rb -T -J
initializer 'generators.rb', <<-RUBY
Rails.application.config.generators do |g|
template = {"orm"=>"activerecord", "unit_testing"=>"rspec", "integration_testing"=>"on", "javascript"=>"jquery", "authentication"=>"devise", "templating"=>"on", "css"=>"on"}
recipes = template.values.flatten
def say_recipe(name); say "\033[36m" + "recipe".rjust(10) + "\033[0m" + " Running #{name} recipe..." end
def say_wizard(text); say "\033[36m" + "wizard".rjust(10) + "\033[0m" + " #{text}" end
@after_blocks = []
def after_bundler(&block); @after_blocks << block; end
# >-----------------------------[ ActiveRecord ]------------------------------<
# Use the default ActiveRecord database store.
say_recipe 'ActiveRecord'
# No additional code required.
# >---------------------------------[ RSpec ]---------------------------------<
# Use RSpec for unit testing for this Rails app.
say_recipe 'RSpec'
gem 'rspec-rails', '>= 2.0.1', :group => [:development, :test]
gem 'sqlite3-ruby', :require => 'sqlite3', :group => [:development, :test]
inject_into_file "config/initializers/generators.rb", :after => "Rails.application.config.generators do |g|\n" do
" g.test_framework = :rspec\n"
after_bundler do
generate 'rspec:install'
# >--------------------------------[ jQuery ]---------------------------------<
# Adds the latest jQuery and Rails UJS helpers for jQuery.
say_recipe 'jQuery'
inside "public/javascripts" do
get "", "rails.js"
get "", "jquery.js"
application do
"\nconfig.action_view.javascript_expansions[:defaults] = %w(jquery rails)\n"
gsub_file "config/application.rb", /# JavaScript.*\n/, ""
gsub_file "config/application.rb", /# config\.action_view\.javascript.*\n/, ""
# >--------------------------------[ Devise ]---------------------------------<
# Utilize Devise for authentication, automatically configured for your selected ORM.
say_recipe 'Devise'
gem 'devise'
gem 'will_paginate'
gem 'exception_notification_rails3', :require => 'exception_notifier'
# Postgres!
gem 'pg'
after_bundler do
generate 'devise:install'
case template['orm']
when 'mongo_mapper'
gem 'mm-devise'
gsub_file 'config/intializers/devise.rb', 'devise/orm/active_record', 'devise/orm/mongo_mapper_active_model'
when 'mongoid'
gsub_file 'config/intializers/devise.rb', 'devise/orm/active_record', 'devise/orm/mongoid'
when 'active_record'
# Nothing to do
generate 'devise user'
# >-----------------------------[ Run Bundler ]-------------------------------<
say_wizard "Running Bundler install. This will take a while."
run 'bundle install'
say_wizard "Running after Bundler callbacks."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.