mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #18174 from bogdan/cleanup_has_many_though_association_count
Remove unneeded special case to calculate size for has_many :through
This commit is contained in:
commit
a862c39b88
1 changed files with 0 additions and 15 deletions
|
@ -13,21 +13,6 @@ module ActiveRecord
|
||||||
@through_association = nil
|
@through_association = nil
|
||||||
end
|
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)
|
def concat(*records)
|
||||||
unless owner.new_record?
|
unless owner.new_record?
|
||||||
records.flatten.each do |record|
|
records.flatten.each do |record|
|
||||||
|
|
Loading…
Reference in a new issue