Post#pools: avoid query when post has no pools.
This commit is contained in:
@@ -1026,8 +1026,9 @@ class Post < ActiveRecord::Base
|
||||
module PoolMethods
|
||||
def pools
|
||||
@pools ||= begin
|
||||
return Pool.none if pool_string.blank?
|
||||
pool_ids = pool_string.scan(/\d+/)
|
||||
Pool.where(["is_deleted = false and id in (?)", pool_ids])
|
||||
Pool.undeleted.where(id: pool_ids).series_first
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user