2007-10-26 05:56:46 +00:00
|
|
|
class Pirate < ActiveRecord::Base
|
|
|
|
belongs_to :parrot
|
|
|
|
has_and_belongs_to_many :parrots
|
2008-02-02 03:27:31 +00:00
|
|
|
has_many :treasures, :as => :looter
|
|
|
|
|
|
|
|
has_many :treasure_estimates, :through => :treasures, :source => :price_estimates
|
2008-05-12 22:46:57 +00:00
|
|
|
|
2009-02-01 01:44:30 +00:00
|
|
|
# These both have :autosave enabled because accepts_nested_attributes_for is used on them.
|
|
|
|
has_one :ship
|
|
|
|
has_many :birds
|
|
|
|
|
|
|
|
accepts_nested_attributes_for :parrots, :birds, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? }
|
2009-02-08 13:23:35 +00:00
|
|
|
accepts_nested_attributes_for :ship, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? }
|
2009-02-01 01:44:30 +00:00
|
|
|
|
2008-05-12 22:46:57 +00:00
|
|
|
validates_presence_of :catchphrase
|
2007-10-26 05:56:46 +00:00
|
|
|
end
|