Skip to content

Instantly share code, notes, and snippets.

View antonfefilov's full-sized avatar
🚀
To infinity and beyond!

Anton Fefilov antonfefilov

🚀
To infinity and beyond!
  • ScienceCast
  • Georgia, Tbilisi
View GitHub Profile

A Capistrano Rails Guide

by Jonathan Rochkind, http://bibwild.wordpress.com

why cap?

Capistrano automates pushing out a new version of your application to a deployment location.

I've been writing and deploying Rails apps for a while, but I avoided using Capistrano until recently. I've got a pretty simple one-host deployment, and even though everyone said Capistrano was great, every time I tried to get started I just got snowed under not being able to figure out exactly what I wanted to do, and figured I wasn't having that much trouble doing it "manually".

sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update
sudo apt-get install postgresql-9.2 postgresql-server-dev-9.2 postgresql-contrib-9.2
sudo su -l postgres
psql -d template1 -p 5433
CREATE EXTENSION IF NOT EXISTS hstore;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
service postgresql stop
/usr/lib/postgresql/9.2/bin/pg_upgrade -b /usr/lib/postgresql/9.1/bin -B /usr/lib/postgresql/9.2/bin -d /var/lib/postgresql/9.1/main/ -D /var/lib/postgresql/9.2/main/ -O "-c config_file=/etc/postgresql/9.2/main/postgresql.conf" -o "-c config_file=/etc/postgresql/9.1/main/postgresql.conf"
#install required packages
apt-get update
apt-get upgrade -y
apt-get install -y git curl build-essential libssl-dev libcurl4-openssl-dev nodejs
#install sqlite3 (optional)
apt-get install libsqlite3-dev sqlite3
#install postgres (optional)
sudo apt-get install postlibpq-dev
@antonfefilov
antonfefilov / deploy.rb
Created January 11, 2014 08:48 — forked from reu/deploy.rb
# Bundler Integration
require "bundler/capistrano"
# Application Settings
set :application, "yourapplicationname"
set :user, "serveruser"
set :deploy_to, "/home/#{user}/rails-applications/#{application}"
set :rails_env, "production"
set :use_sudo, false
set :keep_releases, 3
# config/initializers/active_admin.rb
require 'active_admin_custom_filter'
ActiveAdmin.setup do |config|
# ...
end

Brakeman setup:

Create ignore file, please name it .brakeman-ignore

bin/brakeman --interactive-ignore

Add to script/ci

bin/brakeman --quiet --skip-libs --exit-on-warn --ignore-config=.brakeman-ignore

In Rails 3

NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

# Add these two gems
gem 'ice_cube', '0.9.3'
gem 'squeel', '1.0.16'
# config/initializers/active_admin.rb
require 'active_admin_custom_filter'
ActiveAdmin.setup do |config|
# ...
end