Files
nairobi/app/models/vote.rb
Alberto Miedes Garcés 4783f14eb4 Show voter info in api
2017-01-02 00:13:16 +01:00

14 lines
660 B
Ruby

class Vote < ActsAsVotable::Vote
scope :public_for_api, -> do
joins("FULL OUTER JOIN debates ON votable_type = 'Debate' AND votable_id = debates.id").
joins("FULL OUTER JOIN proposals ON votable_type = 'Proposal' AND votable_id = proposals.id").
joins("FULL OUTER JOIN comments ON votable_type = 'Comment' AND votable_id = comments.id").
where("votable_type = 'Proposal' AND proposals.hidden_at IS NULL OR votable_type = 'Debate' AND debates.hidden_at IS NULL OR votable_type = 'Comment' AND comments.hidden_at IS NULL")
end
def public_voter
User.select("gender, geozone_id, date_of_birth").where(id: self.voter_id).first
end
end