aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/pirate.rb
blob: 6a2416a05ca47d997e0af80e9311abfaaa0b7e4e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Pirate < ActiveRecord::Base
  belongs_to :parrot
  has_and_belongs_to_many :parrots
  has_many :treasures, :as => :looter

  has_many :treasure_estimates, :through => :treasures, :source => :price_estimates

  # 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? }
  accepts_nested_attributes_for :ship, :allow_destroy => true

  validates_presence_of :catchphrase
end