aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/bulb.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-06-30 22:41:18 +0100
committerJon Leighton <j@jonathanleighton.com>2011-06-30 23:39:58 +0100
commit0e225ec583db523a8b7da332eaf689149ed60447 (patch)
treebb18c8a7b672eb7545c36daba2aba2c0a3ce46c0 /activerecord/test/models/bulb.rb
parent6a283d598f243197375266c8b981b66f1b5f10c5 (diff)
downloadrails-0e225ec583db523a8b7da332eaf689149ed60447.tar.gz
rails-0e225ec583db523a8b7da332eaf689149ed60447.tar.bz2
rails-0e225ec583db523a8b7da332eaf689149ed60447.zip
Assign the association attributes to the associated record before the before_initialize callback of the record runs. Fixes #1842.
Diffstat (limited to 'activerecord/test/models/bulb.rb')
-rw-r--r--activerecord/test/models/bulb.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/activerecord/test/models/bulb.rb b/activerecord/test/models/bulb.rb
index 0dcc8d5970..efb98b66e7 100644
--- a/activerecord/test/models/bulb.rb
+++ b/activerecord/test/models/bulb.rb
@@ -4,13 +4,18 @@ class Bulb < ActiveRecord::Base
attr_protected :car_id, :frickinawesome
- attr_reader :scope_after_initialize
+ attr_reader :scope_after_initialize, :attributes_after_initialize
after_initialize :record_scope_after_initialize
def record_scope_after_initialize
@scope_after_initialize = self.class.scoped
end
+ after_initialize :record_attributes_after_initialize
+ def record_attributes_after_initialize
+ @attributes_after_initialize = attributes.dup
+ end
+
def color=(color)
self[:color] = color.upcase + "!"
end
@@ -28,4 +33,4 @@ class Bulb < ActiveRecord::Base
end
class CustomBulb < Bulb
-end \ No newline at end of file
+end