aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/builder/belongs_to.rb
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2017-03-20 07:16:28 +0100
committerGitHub <noreply@github.com>2017-03-20 07:16:28 +0100
commit95911db192cb60047fbfaa2ffed118807a414f2c (patch)
treea2947d163556b799dbcc7117d0fed1386dfdc653 /activerecord/lib/active_record/associations/builder/belongs_to.rb
parent1934e93d2b514df57718ef584a1e81a297992f49 (diff)
parent4c1d22183c9ed4dea74ef60a3cca1891fa588b74 (diff)
downloadrails-95911db192cb60047fbfaa2ffed118807a414f2c.tar.gz
rails-95911db192cb60047fbfaa2ffed118807a414f2c.tar.bz2
rails-95911db192cb60047fbfaa2ffed118807a414f2c.zip
Merge pull request #28479 from kamipo/evaluate_default_block_only_when_necessary
Evaluate the default block only when necessary
Diffstat (limited to 'activerecord/lib/active_record/associations/builder/belongs_to.rb')
-rw-r--r--activerecord/lib/active_record/associations/builder/belongs_to.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/builder/belongs_to.rb b/activerecord/lib/active_record/associations/builder/belongs_to.rb
index 50a1c39ccf..2b9dd8aae8 100644
--- a/activerecord/lib/active_record/associations/builder/belongs_to.rb
+++ b/activerecord/lib/active_record/associations/builder/belongs_to.rb
@@ -121,7 +121,7 @@ module ActiveRecord::Associations::Builder # :nodoc:
def self.add_default_callbacks(model, reflection)
model.before_validation lambda { |o|
- o.association(reflection.name).default o.instance_exec(&reflection.options[:default])
+ o.association(reflection.name).default(&reflection.options[:default])
}
end