Created
April 8, 2012 07:00
-
-
Save mhayes/2335378 to your computer and use it in GitHub Desktop.
Setup a rails application and get going quickly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rails new <APP_NAME> -d mysql -m rails_template.rb | |
gem "zurb-foundation" | |
gem "backbone-on-rails", "~> 0.9.2" | |
gem "mysql2" | |
gem "jbuilder" | |
gem "factory_girl_rails", "~> 1.7.0", :group => [:development, :test] | |
gem "mocha", "~> 0.10.5", :require => false, :group => [:test] | |
gem "capybara", :group => [:test] | |
gem_group :development do | |
gem "capistrano" | |
gem "capistrano-ext" | |
end | |
run "bundle install" | |
capify! | |
create_file "config/deploy/production.rb" | |
remove_file "public/index.html" | |
application do | |
<<-eos | |
config.generators do |g| | |
g.test_framework :test_unit, :fixture_replacement => :factory_girl | |
end | |
eos | |
end | |
remove_file "test/test_helper.rb" | |
create_file "test/test_helper.rb", <<-eos | |
ENV["RAILS_ENV"] = "test" | |
require File.expand_path('../../config/environment', __FILE__) | |
require 'rails/test_help' | |
class ActiveSupport::TestCase | |
require "test/unit" | |
require "mocha" | |
end | |
eos | |
create_file "test/integration_test_helper.rb", <<-eos | |
require "test_helper" | |
require "capybara/rails" | |
class ActionDispatch::IntegrationTest | |
include Capybara::DSL | |
teardown do | |
Capybara.reset_sessions! # Forget the (simulated) browser state | |
Capybara.use_default_driver | |
ActionMailer::Base.deliveries = [] | |
end | |
end | |
eos | |
db_yml_file = <<-eos | |
defaults: &defaults | |
adapter: mysql2 | |
encoding: utf8 | |
reconnect: false | |
pool: 5 | |
username: root | |
password: | |
development: | |
database: #{app_name}_development | |
<<: *defaults | |
test: | |
database: #{app_name}_test | |
<<: *defaults | |
production: | |
database: #{app_name}_development | |
<<: *defaults | |
eos | |
remove_file "config/database.yml" | |
create_file "config/database.yml", db_yml_file | |
create_file "config/database.yml.sample", db_yml_file | |
run "bundle exec rake db:create RAILS_ENV=development" | |
run "bundle exec rake db:migrate RAILS_ENV=development" | |
# Setup Foundation for HAML | |
remove_file "app/views/layouts/application.html.erb" | |
generate "foundation:install" | |
generate "foundation:layout" | |
# Setup Backbone | |
generate "backbone:install --javascript" | |
# Clean up sprockets file | |
remove_file "app/assets/javascripts/application.js" | |
create_file "app/assets/javascripts/application.js", <<-eos | |
//= require jquery | |
//= require jquery_ujs | |
//= require foundation | |
//= require underscore | |
//= require backbone | |
//= require #{app_name} | |
//= require_tree ../templates | |
//= require_tree ./models | |
//= require_tree ./collections | |
//= require_tree ./views | |
//= require_tree ./routers | |
eos | |
remove_dir "test/fixtures" | |
create_file "test/factories.rb", <<-eos | |
FactoryGirl.define do | |
end | |
eos | |
append_to_file ".gitignore", "config/*.yml" | |
git :init | |
git :add => "." | |
git :commit => "-m 'initial commit'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment