aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorLes Fletcher <les.fletcher@gmail.com>2011-07-21 01:36:02 -0700
committerGabriel Horner <gabriel.horner@gmail.com>2011-07-24 00:31:28 -0400
commitf956759f8ab656484add2d5bc6e8f6f4add79469 (patch)
tree3783716dfd568e2b9c61dfb4daf310031ebb0ef1 /activerecord/lib/active_record
parentd33eb07543aed1a07f9efe40ff7edc983b401957 (diff)
downloadrails-f956759f8ab656484add2d5bc6e8f6f4add79469.tar.gz
rails-f956759f8ab656484add2d5bc6e8f6f4add79469.tar.bz2
rails-f956759f8ab656484add2d5bc6e8f6f4add79469.zip
fix after_initialize edge case (close #2074 and close #2175)
fix behavior when after_initialize is defined and a block is passed to Base.create
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/base.rb3
1 files changed, 1 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 2c162a6fc8..4136868b39 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -504,8 +504,7 @@ module ActiveRecord #:nodoc:
if attributes.is_a?(Array)
attributes.collect { |attr| create(attr, options, &block) }
else
- object = new(attributes, options)
- yield(object) if block_given?
+ object = new(attributes, options, &block)
object.save
object
end