Skip to content

Instantly share code, notes, and snippets.

View erpe's full-sized avatar
🏠
Working from home

rene paulokat erpe

🏠
Working from home
  • AustauschKompass
  • Berlin
  • X @er_pe
View GitHub Profile
@erpe
erpe / gist:6174427
Last active December 20, 2015 18:18
using chained scopes for facetted querying
class Program < ActiveRecord::Base
belongs_to :associated_school
scope :active, -> { where("active = ?", true) }
scope :inactive, -> { where("active = ?", false)}
scope :in_country, ->(country) {
joins(associated_school:
{school: :address}
).where(addresses:
@erpe
erpe / unicorn_cap_task.rb
Created April 18, 2013 11:11
capistrano task to deal with unicorn restarts during deployment
namespace :unicorn do
desc "Zero-downtime restart of Unicorn"
task :restart, :except => { :no_release => true } do
# you can use this signal if preload_app == false
# run "kill -s HUP `cat #{shared_path}/pids/unicorn.pid`"
# use this signal if preload_app == true
run "kill -s USR2 `cat #{shared_path}/pids/unicorn.pid`"
# give unicorn some seconds to create unicorn.pid.oldbin