提交 9f0cd30d 编写于 作者: R Rafael Mendonça França

Merge pull request #15701 from zzak/issue_15496

Open extension point for defining options in build_through_record
......@@ -82,12 +82,16 @@ def build_through_record(record)
@through_records[record.object_id] ||= begin
ensure_mutable
through_record = through_association.build through_scope_attributes
through_record = through_association.build(*options_for_through_record)
through_record.send("#{source_reflection.name}=", record)
through_record
end
end
def options_for_through_record
[through_scope_attributes]
end
def through_scope_attributes
scope.where_values_hash(through_association.reflection.name.to_s).except!(through_association.reflection.foreign_key)
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册