Skip to content

Instantly share code, notes, and snippets.

View tborisova's full-sized avatar

Tsvetelina Borisova tborisova

View GitHub Profile
@tborisova
tborisova / ability.rb
Last active August 29, 2015 14:14 — forked from hrdwdmrbl/ability.rb
class Ability
include CanCan::Ability
def marshal_dump
#blocks cannot be cached
@rules.reject{|rule| rule.instance_variable_get :@block }.map{|rule| Marshal.dump(rule) }
end
def marshal_load array
#blocks cannot be cached, so blocks must be re-defined
can :read, Comment do |comment|
@tborisova
tborisova / account.rb
Last active August 29, 2015 14:12 — forked from fauxparse/account.rb
class Account
include Mongoid::Document
include Mongoid::Timestamps
field :subdomain, :type => String
embeds_many :users
accepts_nested_attributes_for :users
validates_presence_of :name, :subdomain
validates_uniqueness_of :subdomain, :case_sensitive => false