View gist:4588699
class Ability
include CanCan::Ability
def initialize(user)
def initialize(user)
user ||= # guest user (not logged in)
# abilities defined here
if user.role == "admin"
View gist:1291887
require 'tsort'
module Rails
module Initializable
def self.included(base)
base.extend ClassMethods
class Initializer
attr_reader :name, :block
View cascade
# Gives the ability to cascade upward for an attribute in a nested_set
# So, for example, if a project does not have a client specified, it will
# inherit the client of its parent, or further ancestor.
module Cascade
def self.included(klass)
module ClassMethods
def cascades(*args)
View Result of query ...
# doesn't include any joins from the :include => eager load call!
Payment Load (0.3ms) SELECT * FROM `payments` WHERE (`payments`.`paid_at` BETWEEN '2010-03-01 00:00:00' AND '2010-03-31 23:59:59') ORDER BY paid_at ASC
View deploy.rb
set :sync_directories, ["public/assets", "public/galleries"]
set :sync_backups, 3
View ModelCode.rb
class Person < ActiveRecord::Base
# needs_loan :boolean(1)
has_many :loan_requests
def update_needs_loan!
needs_loan = loan_requests.any? { |l| }