Skip to content

Commit 507be83

Browse files
committed
virtual_has_many default source
1 parent 5a12ae4 commit 507be83

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/active_record/virtual_attributes/virtual_reflections.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ def virtual_has_one(name, uses: nil, **options)
1414
add_virtual_reflection(reflection, name, uses)
1515
end
1616

17-
def virtual_has_many(name, uses: nil, source: nil, through: nil, **options)
17+
def virtual_has_many(name, uses: nil, source: name, through: nil, **options)
1818
define_method(:"#{name.to_s.singularize}_ids") do
1919
records = send(name)
2020
records.respond_to?(:ids) ? records.ids : records.collect(&:id)
2121
end
22-
define_delegate(name, source || name, :to => through, :allow_nil => true, :default => []) if through
22+
define_delegate(name, source, :to => through, :allow_nil => true, :default => []) if through
2323
reflection = ActiveRecord::Associations::Builder::HasMany.build(self, name, nil, options)
2424
add_virtual_reflection(reflection, name, uses)
2525
end

0 commit comments

Comments
 (0)