aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/ship.rb
blob: a96e38ab41c0344c70e7d25985b94975ef7fa02a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
class Ship < ActiveRecord::Base
  self.record_timestamps = false

  belongs_to :pirate
  belongs_to :update_only_pirate, :class_name => 'Pirate'
  has_many :parts, :class_name => 'ShipPart', :autosave => true

  accepts_nested_attributes_for :pirate, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? }
  accepts_nested_attributes_for :update_only_pirate, :update_only => true

  validates_presence_of :name
end