Sha256: 74b9c6bf7677c2dec4b4203432083f966b2cd9ac7365ad0c62c2a856942315a0

Contents?: true

Size: 1.37 KB

Versions: 47

Compression:

Stored size: 1.37 KB

Contents

require 'uuidtools'

class Tag < ActiveRecord::Base
  acts_as_tree :dependent => :destroy, :order => "name"
  before_destroy :add_destroyed_tag
  attr_accessible :name

  def to_s
    name
  end

  def add_destroyed_tag
    # Proof for the tests that the destroy rather than the delete method was called:
    DestroyedTag.create(:name => name)
  end
end

class DestroyedTag < ActiveRecord::Base
  attr_accessible :name
end

class User < ActiveRecord::Base
  acts_as_tree :parent_column_name => "referrer_id",
    :name_column => 'email',
    :hierarchy_class_name => 'ReferralHierarchy',
    :hierarchy_table_name => 'referral_hierarchies'

  has_many :contracts

  def indirect_contracts
    Contract.where(:user_id => descendant_ids)
  end

  attr_accessible :email, :referrer

  def to_s
    email
  end
end

class Contract < ActiveRecord::Base
  belongs_to :user
end

class Label < ActiveRecord::Base
  attr_accessible :name # < - make sure order doesn't matter
  acts_as_tree :order => "sort_order",
    :parent_column_name => "mother_id",
    :dependent => :destroy

  def to_s
    "#{self.class}: #{name}"
  end
end

class EventLabel < Label
end

class DateLabel < Label
end

class DirectoryLabel < Label
end

class CuisineType < ActiveRecord::Base
  acts_as_tree
end

module Namespace
  class Type < ActiveRecord::Base
    acts_as_tree :dependent => :destroy
    attr_accessible :name
  end
end

Version data entries

47 entries across 47 versions & 2 rubygems

Version Path
closure_tree-4.0.0 spec/support/models.rb
lalala-4.0.0.dev.136 vendor/deps/closure_tree/spec/support/models.rb
lalala-4.0.0.dev.135 vendor/deps/closure_tree/spec/support/models.rb
lalala-4.0.0.dev.134 vendor/deps/closure_tree/spec/support/models.rb
lalala-4.0.0.dev.133 vendor/deps/closure_tree/spec/support/models.rb
lalala-4.0.0.dev.132 vendor/deps/closure_tree/spec/support/models.rb
lalala-4.0.0.dev.131 vendor/deps/closure_tree/spec/support/models.rb
lalala-4.0.0.dev.129 vendor/deps/closure_tree/spec/support/models.rb
lalala-4.0.0.dev.128 vendor/deps/closure_tree/spec/support/models.rb
lalala-4.0.0.dev.126 vendor/deps/closure_tree/spec/support/models.rb
lalala-4.0.0.dev.125 vendor/deps/closure_tree/spec/support/models.rb
lalala-4.0.0.dev.124 vendor/deps/closure_tree/spec/support/models.rb
lalala-4.0.0.dev.123 vendor/deps/closure_tree/spec/support/models.rb
lalala-4.0.0.dev.118 vendor/deps/closure_tree/spec/support/models.rb
lalala-4.0.0.dev.116 vendor/deps/closure_tree/spec/support/models.rb
lalala-4.0.0.dev.114 vendor/deps/closure_tree/spec/support/models.rb
lalala-4.0.0.dev.113 vendor/deps/closure_tree/spec/support/models.rb
lalala-4.0.0.dev.111 vendor/deps/closure_tree/spec/support/models.rb
lalala-4.0.0.dev.109 vendor/deps/closure_tree/spec/support/models.rb
lalala-4.0.0.dev.107 vendor/deps/closure_tree/spec/support/models.rb