提交 a862c39b 编写于 作者: S Sean Griffin

Merge pull request #18174 from bogdan/cleanup_has_many_though_association_count

Remove unneeded special case to calculate size for has_many :through
......@@ -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|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册