Skip to content

Commit ec1aa50

Browse files
committed
Revert "Merge pull request rails#48406 from rails/revert-46790-singular-association-refactor"
This reverts commit f6f2b2d, reversing changes made to 3e01b26.
1 parent 3255411 commit ec1aa50

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

activerecord/lib/active_record/associations/has_one_association.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ def set_new_record(record)
9292
replace(record, false)
9393
end
9494

95+
def replace_keys(record, force: false)
96+
# Has one association doesn't have foreign keys to replace.
97+
end
98+
9599
def remove_target!(method)
96100
case method
97101
when :delete

activerecord/lib/active_record/associations/singular_association.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def _create_record(attributes, raise_error = false, &block)
5757
reflection.klass.transaction do
5858
record = build(attributes, &block)
5959
saved = record.save
60-
set_new_record(record)
60+
replace_keys(record, force: true)
6161
raise RecordInvalid.new(record) if !saved && raise_error
6262
record
6363
end

0 commit comments

Comments
 (0)