53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/hickey/domain_detector/associations.rb', line 53
def has_many_through(owner, reflection, attr_value)
through_reflection = reflection.through_reflection
Proc.new do
owner_associations = owner.send(reflection.name)
target = attr_value.accept_for_hickey(reflection.klass, self)
target.each do |record|
association = owner_associations.send(:construct_join_attributes, record)
proxy = through_reflection.klass.send(:with_scope, :create => association) do
visit_hash(through_reflection.klass, {})
end
owner_associations.proxy_target << proxy
end
end
end
|