2007-10-26 01:56:46 -04:00
|
|
|
class Parrot < ActiveRecord::Base
|
2011-11-29 10:34:22 -05:00
|
|
|
self.inheritance_column = :parrot_sti_class
|
|
|
|
|
2007-10-26 01:56:46 -04:00
|
|
|
has_and_belongs_to_many :pirates
|
|
|
|
has_and_belongs_to_many :treasures
|
2007-11-20 16:53:22 -05:00
|
|
|
has_many :loots, :as => :looter
|
2008-08-15 21:49:22 -04:00
|
|
|
alias_attribute :title, :name
|
2009-01-31 20:44:30 -05:00
|
|
|
|
|
|
|
validates_presence_of :name
|
2010-01-08 14:47:49 -05:00
|
|
|
|
|
|
|
attr_accessor :cancel_save_from_callback
|
|
|
|
before_save :cancel_save_callback_method, :if => :cancel_save_from_callback
|
|
|
|
def cancel_save_callback_method
|
2014-12-15 01:10:15 -05:00
|
|
|
throw(:abort)
|
2010-01-08 14:47:49 -05:00
|
|
|
end
|
2007-10-26 01:56:46 -04:00
|
|
|
end
|
2007-11-26 17:46:11 -05:00
|
|
|
|
|
|
|
class LiveParrot < Parrot
|
|
|
|
end
|
|
|
|
|
|
|
|
class DeadParrot < Parrot
|
2014-09-22 13:12:19 -04:00
|
|
|
belongs_to :killer, :class_name => 'Pirate', foreign_key: :killer_id
|
2007-11-26 17:46:11 -05:00
|
|
|
end
|
2013-05-13 17:10:23 -04:00
|
|
|
|
|
|
|
class FunkyParrot < Parrot
|
|
|
|
before_destroy do
|
|
|
|
raise "before_destroy was called"
|
|
|
|
end
|
|
|
|
end
|