aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2015-01-28 09:36:42 -0700
committerSean Griffin <sean@thoughtbot.com>2015-01-28 09:53:38 -0700
commit56a3d5ec9183a9bcbf140d4102d45e3928f2617a (patch)
treee83642e06544893dd8747d6f5dad2847ed4ee741 /activerecord/test/models
parent58047ebdf3da86a8ed17cb269c5d4d944d1c2d88 (diff)
downloadrails-56a3d5ec9183a9bcbf140d4102d45e3928f2617a.tar.gz
rails-56a3d5ec9183a9bcbf140d4102d45e3928f2617a.tar.bz2
rails-56a3d5ec9183a9bcbf140d4102d45e3928f2617a.zip
Don't redefine autosave association callbacks in nested attrs
These callbacks will already have been defined when the association was built. The check against `reflection.autosave` happens at call time, not at define time, so simply modifying the reflection is sufficient. Fixes #18704
Diffstat (limited to 'activerecord/test/models')
-rw-r--r--activerecord/test/models/ship.rb1
-rw-r--r--activerecord/test/models/treasure.rb1
2 files changed, 2 insertions, 0 deletions
diff --git a/activerecord/test/models/ship.rb b/activerecord/test/models/ship.rb
index c2f6d492d8..312caef604 100644
--- a/activerecord/test/models/ship.rb
+++ b/activerecord/test/models/ship.rb
@@ -4,6 +4,7 @@ class Ship < ActiveRecord::Base
belongs_to :pirate
belongs_to :update_only_pirate, :class_name => 'Pirate'
has_many :parts, :class_name => 'ShipPart'
+ has_many :treasures
accepts_nested_attributes_for :parts, :allow_destroy => true
accepts_nested_attributes_for :pirate, :allow_destroy => true, :reject_if => proc(&:empty?)
diff --git a/activerecord/test/models/treasure.rb b/activerecord/test/models/treasure.rb
index a69d3fd3df..ffc65466d5 100644
--- a/activerecord/test/models/treasure.rb
+++ b/activerecord/test/models/treasure.rb
@@ -1,6 +1,7 @@
class Treasure < ActiveRecord::Base
has_and_belongs_to_many :parrots
belongs_to :looter, :polymorphic => true
+ belongs_to :ship
has_many :price_estimates, :as => :estimate_of
has_and_belongs_to_many :rich_people, join_table: 'peoples_treasures', validate: false