Sha256: 081b8d5b65cc79e9dc0aa7ce82ba951f8d70754126435b485361de3d3d8e21f6
Contents?: true
Size: 1 KB
Versions: 15
Compression:
Stored size: 1 KB
Contents
module Dorsale module CustomerVault class Person < ActiveRecord::Base self.abstract_class = true after_destroy :destroy_links acts_as_taggable def tags_on(*args) super(*args).order(:name) end has_many :comments, -> { order("id DESC") }, class_name: ::Dorsale::Comment, as: :commentable, dependent: :destroy has_one :address, class_name: ::Dorsale::Address, as: :addressable, inverse_of: :addressable, dependent: :destroy has_many :tasks, class_name: ::Dorsale::Flyboy::Task, as: :taskable, dependent: :destroy accepts_nested_attributes_for :address, allow_destroy: true def links a = Link.where(alice_id: self.id, alice_type: self.class).map {|l| {title: l.title, person: l.bob, origin: l}} b = Link.where(bob_id: self.id, bob_type: self.class).map {|l| {title: l.title, person: l.alice, origin: l}} return a + b end def destroy_links links.map{ |l| l[:origin].destroy! } end end end end
Version data entries
15 entries across 15 versions & 1 rubygems