Skip to content

Instantly share code, notes, and snippets.

@caike
Created June 23, 2012 15:18
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save caike/2978633 to your computer and use it in GitHub Desktop.
Save caike/2978633 to your computer and use it in GitHub Desktop.
Rails 3.2.6 template w/ Twitter Bootstrap
app_name = ARGV[0]
initial_resource_name = ask('What is your initial resource ?')
remove_file 'Gemfile'
create_file 'Gemfile', <<-eos
source 'https://rubygems.org'
gem 'rails', '3.2.6'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
group :development, :test do
gem 'evergreen', require: 'evergreen/rails'
gem 'rspec-rails'
gem 'debugger'
end
group :test do
gem 'factory_girl_rails'
end
gem 'pg'
gem 'twitter-bootstrap-rails', git: 'https://github.com/seyhunak/twitter-bootstrap-rails.git'
gem 'simple_form'
eos
remove_file 'config/database.yml'
# Skipping production db because Heroku
# overrides this anyway
create_file 'config/database.yml', <<-eos
development: &defaults
adapter: postgresql
database: #{app_name.downcase}_development
min_messages: WARNING
test:
<<: *defaults
database: #{app_name.downcase}_test
eos
run 'bundle install'
remove_file 'public/index.html'
remove_file 'app/assets/images/rails.png'
remove_dir 'test'
generate 'rspec:install'
run "echo '--colour' >> .rspec"
rake 'db:create'
generate 'scaffold', initial_resource_name
rake 'db:migrate'
rake 'db:test:prepare'
root_route = "#{initial_resource_name.downcase}s#index"
route "root to: '#{root_route}'"
remove_file 'app/assets/stylesheets/scaffolds.css.scss'
generate 'bootstrap:install'
generate 'bootstrap:layout', '-f', 'application', 'fluid'
generate 'bootstrap:themed', '-f', "#{initial_resource_name.downcase}s" # String#pluralize, Y U NO WORK ?
generate 'simple_form:install', '--bootstrap'
inject_into_file 'spec/spec_helper.rb', :before => "end" do
<<-eos
##
# Raises error if missing translation key
##
config.before(:all, type: :controller) do
@_i18n_exception_handler = I18n.exception_handler
I18n.exception_handler = lambda { |*args| raise args.first.to_s }
end
config.after(:all, type: :controller) do
I18n.exception_handler = @_i18n_exception_handler
end
config.before(:all, type: :request) do
@_i18n_exception_handler = I18n.exception_handler
I18n.exception_handler = lambda { |*args| raise args.first.to_s }
end
config.after(:all, type: :request) do
I18n.exception_handler = @_i18n_exception_handler
end
eos
end
run 'cp config/database.yml config/database.example'
run "echo 'config/database.yml' >> .gitignore"
# commit to git
git :init
git :add => "."
say <<-eos
============================================================================
w00t w00t rails app created with template
eos
@caike
Copy link
Author

caike commented Jun 23, 2012

Usage rails new <app_name> -m https://gist.github.com/raw/2978633/fb0c8f2892e168876d9de1a2cf1a66646c14a8ec/template.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment