mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
5dbc9d40a4
Signed-off-by: Michael Koziarski <michael@koziarski.com> Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com> [#1892 state:committed]
16 lines
629 B
Ruby
16 lines
629 B
Ruby
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, :reject_if => proc { |attributes| attributes.empty? }
|
|
|
|
validates_presence_of :catchphrase
|
|
end
|