mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
parent
cf4f05a7d4
commit
4c1d22183c
2 changed files with 3 additions and 3 deletions
|
@ -21,8 +21,8 @@ module ActiveRecord
|
|||
self.target = record
|
||||
end
|
||||
|
||||
def default(record)
|
||||
writer(record) if reader.nil?
|
||||
def default(&block)
|
||||
writer(instance_exec(&block)) if reader.nil?
|
||||
end
|
||||
|
||||
def reset
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue