bouchard/thumbs_up — pull request #57 by shammael (2012-10-18 15:09:08+00:00)
Title: Generated sql for plusminus_tally is invalid in SQLite

Error message is:
`ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: true: SELECT songs.*, SUM(CASE votes.vote WHEN true THEN 1 WHEN false THEN -1 ELSE 0 END) AS plusminus_tally, COUNT(votes.id) AS vote_count FROM "songs" LEFT OUTER JOIN votes ON songs.id = votes.voteable_id AND votes.voteable_type = 'Song' WHERE "songs"."event_id" = 1 GROUP BY songs.id ORDER BY plusminus_tally DESC, plusminus_tally LIMIT 1`

Changed the code in CASE to be:

'CASE votes.vote WHEN votes.vote = 'true' THEN 1 WHEN votes.vote = 'false' THEN -1 ELSE 0 END`

I also added another helper method to detect sqlite.