Skip to content

Commit

Permalink
Remove unneeded special case to calculate size for has_many :through
Browse files Browse the repository at this point in the history
All cases are properly handled in CollectionAssociation
for all subclasses of this association
  • Loading branch information
bogdan committed Dec 23, 2014
1 parent be2b98b commit d03da59
Showing 1 changed file with 0 additions and 15 deletions.
Expand Up @@ -13,21 +13,6 @@ def initialize(owner, reflection)
@through_association = nil
end

# Returns the size of the collection by executing a SELECT COUNT(*) query
# if the collection hasn't been loaded, and by calling collection.size if
# it has. If the collection will likely have a size greater than zero,
# and if fetching the collection will be needed afterwards, one less
# SELECT query will be generated by using #length instead.
def size
if has_cached_counter?
owner._read_attribute cached_counter_attribute_name(reflection)
elsif loaded?
target.size
else
super
end
end

def concat(*records)
unless owner.new_record?
records.flatten.each do |record|
Expand Down

0 comments on commit d03da59

Please sign in to comment.