avoids postgres exception regarding subquery limits

We have apparently reached a postgres limit for the number of
attributes we query. Using ids instead of the proposal objects seems to
fix it

Using `Array` and `map` instead of `pluck`, because the proposals
attribute can be a single object
This commit is contained in:
rgarcia
2017-08-02 21:34:40 +02:00
parent 113d8a0f28
commit 43b636de09

View File

@@ -91,7 +91,7 @@ class User < ActiveRecord::Base
end
def proposal_votes(proposals)
voted = votes.for_proposals(proposals)
voted = votes.for_proposals(Array(proposals).map(&:id))
voted.each_with_object({}) { |v, h| h[v.votable_id] = v.value }
end