mirror of https://github.com/rails/rails
Merge pull request #46790 from lazaronixon/singular-association-refactor
Small refactor on build singular association
This commit is contained in:
commit
68664aee48
|
@ -87,6 +87,10 @@ module ActiveRecord
|
|||
replace(record, false)
|
||||
end
|
||||
|
||||
def replace_keys(record, force: false)
|
||||
# Has one association doesn't have foreign keys to replace.
|
||||
end
|
||||
|
||||
def remove_target!(method)
|
||||
case method
|
||||
when :delete
|
||||
|
|
|
@ -57,7 +57,7 @@ module ActiveRecord
|
|||
reflection.klass.transaction do
|
||||
record = build(attributes, &block)
|
||||
saved = record.save
|
||||
set_new_record(record)
|
||||
replace_keys(record, force: true)
|
||||
raise RecordInvalid.new(record) if !saved && raise_error
|
||||
record
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue