vote_fu
vote_fu copied to clipboard
Conflict with PostgresSQL
Hi Pete,
I've been using vote_fu for my simple web app (http://www.playgroundrus.com) on AWS. Since it's quite expensive for little traffic, I moved it to Heroku.
I didn't realize that Heroku uses PostgresSQL, and so far I found one particular method that's causing an error, tally.
I have this line in a controller,
@creep = @playground.creeps.tally({:limit => 1, :order => "creep.votes_for"})[0]
And it causes the following error.
ActiveRecord::StatementInvalid (PGError: ERROR: column "creeps.id" must appear in the GROUP BY clause or be used in an aggregate function : SELECT creeps.*, COUNT(votes.id) AS count FROM "creeps" LEFT OUTER JOIN votes ON creeps.id = votes.voteable_id WHERE ((votes.voteable_type = E'Creep') AND ("creeps".playground_id = 57)) AND ("creeps".playground_id = 57) GROUP BY votes.voteable_id HAVING COUNT(votes.id) > 0 ORDER BY count DESC LIMIT 1):
I tried just tally method on Creep object, and I get the following error.
creeps = Creep.tally
ActiveRecord::StatementInvalid: PGError: ERROR: column "creeps.id" must appear in the GROUP BY clause or be used in an aggregate function : SELECT creeps.*, COUNT(votes.id) AS count FROM "creeps" LEFT OUTER JOIN votes ON creeps.id = votes.voteable_id WHERE (votes.voteable_type = E'Creep') GROUP BY votes.voteable_id HAVING COUNT(votes.id) > 0 ORDER BY count DESC
I am sort of noob, and I am afraid I might make it worse if I start editing acts_as_voteable.rb... If you could find out a solution, it would be much appreciated.
Thank you,
That's interesting. Thanks for the report. I've noticed a few issues here and there with PostgrSQL. I'll see what I can find.
Thanks, Pete! I've been using it for some time, and I think it's a great plugin. Two big thumbs up, mate! Look forward to your fix.
Cheers,
Had to do the fix to play nice with Heroku - I've explained the changes here - http://allaboutruby.wordpress.com/2009/12/06/vote_fu-to-work-in-heroku-postgres/