mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
This way we don't define all the validation methods for all associations by default, but only when needed. [#3355 state:resolved]
11 lines
306 B
Ruby
11 lines
306 B
Ruby
class Ship < ActiveRecord::Base
|
|
self.record_timestamps = false
|
|
|
|
belongs_to :pirate
|
|
has_many :parts, :class_name => 'ShipPart', :autosave => true
|
|
|
|
accepts_nested_attributes_for :pirate, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? }
|
|
|
|
validates_presence_of :name
|
|
end
|