Logical Reality Design LRDesign

View gist:4588699
1 2 3 4 5 6 7 8 9 10
class Ability
include CanCan::Ability
 
def initialize(user)
def initialize(user)
user ||= User.new # guest user (not logged in)
# abilities defined here
 
if user.role == "admin"
View gist:1291887
1 2 3 4 5 6 7 8 9 10
require 'tsort'
 
module Rails
module Initializable
def self.included(base)
base.extend ClassMethods
end
 
class Initializer
attr_reader :name, :block
View cascade
1 2 3 4 5 6 7 8 9 10
# 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)
klass.extend(ClassMethods)
end
module ClassMethods
def cascades(*args)
View Result of query ...
1 2
# 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
1 2
set :sync_directories, ["public/assets", "public/galleries"]
set :sync_backups, 3
View ModelCode.rb
1 2 3 4 5 6 7 8 9
class Person < ActiveRecord::Base
# needs_loan :boolean(1)
has_many :loan_requests
 
def update_needs_loan!
needs_loan = loan_requests.any? { |l| l.active? }
save!
end
end
Something went wrong with that request. Please try again.