diff options
author | Ian White <ian.w.white@gmail.com> | 2010-05-18 10:28:26 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-05-18 16:13:00 +0200 |
commit | b439d85a19c02eefab1ee308fff334ac1049524d (patch) | |
tree | 75fa2fa34a6d8ac398d25755d0b84de416500d5c /activerecord/test/models | |
parent | ce20b93606195eff1ea2dfeb2aa311130dd9977e (diff) | |
download | rails-b439d85a19c02eefab1ee308fff334ac1049524d.tar.gz rails-b439d85a19c02eefab1ee308fff334ac1049524d.tar.bz2 rails-b439d85a19c02eefab1ee308fff334ac1049524d.zip |
Nested records (re: autosave) are now updated even when the intermediate parent record is unchanged [#4242 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/ship.rb | 3 | ||||
-rw-r--r-- | activerecord/test/models/ship_part.rb | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/activerecord/test/models/ship.rb b/activerecord/test/models/ship.rb index 75c792d176..3da031946f 100644 --- a/activerecord/test/models/ship.rb +++ b/activerecord/test/models/ship.rb @@ -3,8 +3,9 @@ class Ship < ActiveRecord::Base belongs_to :pirate belongs_to :update_only_pirate, :class_name => 'Pirate' - has_many :parts, :class_name => 'ShipPart', :autosave => true + has_many :parts, :class_name => 'ShipPart' + accepts_nested_attributes_for :parts, :allow_destroy => 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 diff --git a/activerecord/test/models/ship_part.rb b/activerecord/test/models/ship_part.rb index 0a606db239..b6a8a506b4 100644 --- a/activerecord/test/models/ship_part.rb +++ b/activerecord/test/models/ship_part.rb @@ -1,5 +1,7 @@ class ShipPart < ActiveRecord::Base belongs_to :ship + has_many :trinkets, :class_name => "Treasure", :as => :looter + accepts_nested_attributes_for :trinkets, :allow_destroy => true validates_presence_of :name end
\ No newline at end of file |