This is a basic Rails project setup on a Mac that helps me get up to speed when building a new app.
It is by no means a guide, reference or best practice.
-
rails new project_name -d postgresql -
cd project_name -
cp config/database.yml config/example.database.yml -
vim config/database.ymldevelopment: adapter: postgresql encoding: unicode database: project_name_development template: template0 pool: 5 username: username password: userpass test: adapter: postgresql encoding: unicode database: project_name_test template: template0 pool: 5 username: username password: userpass min_messages: warning -
vim .gitignore(...) .DS_Store /config/database.yml -
git init -
git add -A -
git commit -m "Initial setup."
(Start PostgreSQL daemon if not running)
rake db:create
(Make jQuery play nice with turbolinks)
-
vim Gemfile(...) # jQuery :heart: Turbolinks gem 'jquery-turbolinks' -
bundle install -
vim app/assets/javascripts/application.js//= require jquery //= require jquery.turbolinks //= require jquery_ujs // // ... your other scripts here ... // //= require turbolinks
-
vim Gemfile(...) # Unicorn (aka make your app fly) gem 'unicorn' -
bundle install -
vim Procfileweb: bundle exec unicorn -p $PORT -c ./config/unicorn.rb -
vim config/unicorn.rbworker_processes 3 timeout 30 before_fork do |server, worker| Signal.trap 'TERM' do puts 'Unicorn master intercepting TERM and sending myself QUIT instead' Process.kill 'QUIT', Process.pid end defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! end after_fork do |server, worker| Signal.trap 'TERM' do puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT' end defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection end -
foreman start
-
vim Gemfile(...) # Auth gem "devise" -
bundle install -
rails generate devise:install -
vim config/environments/development.rb(# config.action_view.raise_on_missing_translations = true) config.action_mailer.default_url_options = { host: 'localhost', port: 5000 } (end) -
rails g controller home index -
vim config/routes.rb(Rails.application.routes.draw do) root 'home#index' (...) -
vim config/application.rb(config.active_record.raise_in_transactional_callbacks = true) config.assets.initialize_on_precompile = false (end)
-
vim Gemfile(...) # Bootstrapping gem "therubyracer" gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS gem "twitter-bootstrap-rails" -
bundle install -
rails generate bootstrap:install less -
vim app/assets/stylesheets/application.css(* file per style scope.) *= require bootstrap_and_overrides (*= require_tree .)