Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #15701 from zzak/issue_15496
Browse files Browse the repository at this point in the history
Open extension point for defining options in build_through_record
  • Loading branch information
rafaelfranca committed Jun 13, 2014
1 parent 1d56f05 commit 8a3895b
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -84,12 +84,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
Expand Down

0 comments on commit 8a3895b

Please sign in to comment.