2017-07-09 13:41:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2008-01-31 02:50:15 -05:00
|
|
|
class Pet < ActiveRecord::Base
|
2010-11-11 11:41:15 -05:00
|
|
|
attr_accessor :current_user
|
|
|
|
|
2011-11-29 13:58:41 -05:00
|
|
|
self.primary_key = :pet_id
|
2016-08-06 13:37:57 -04:00
|
|
|
belongs_to :owner, touch: true
|
2009-03-09 09:42:51 -04:00
|
|
|
has_many :toys
|
2016-04-05 23:46:55 -04:00
|
|
|
has_many :pet_treasures
|
|
|
|
has_many :treasures, through: :pet_treasures
|
2016-08-06 12:26:20 -04:00
|
|
|
has_many :persons, through: :treasures, source: :looter, source_type: "Person"
|
2010-11-11 11:41:15 -05:00
|
|
|
|
2010-11-30 21:46:56 -05:00
|
|
|
class << self
|
|
|
|
attr_accessor :after_destroy_output
|
|
|
|
end
|
|
|
|
|
2010-11-11 11:41:15 -05:00
|
|
|
after_destroy do |record|
|
2010-11-30 21:46:56 -05:00
|
|
|
Pet.after_destroy_output = record.current_user
|
2010-11-11 11:41:15 -05:00
|
|
|
end
|
2009-03-09 09:42:51 -04:00
|
|
|
end
|