rails mysql2 gem error for .include?
This works locally, but not on production server.
Using ubuntu 10.04, rails 3.0.7, ruby 1.9.2 and mysql2 gem
what am I doing wrong?
haml view:
- unless current_user.surveys.include?(survey)
Returns
ActionView::Template::Error (Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL))) LIMIT 1' at line 1: SELECT 1 FROM `surveys` INNER JOIN `response_sets` ON `surveys`.id = `response_set开发者_如何学Pythons`.survey_id WHERE `surveys`.`id` = 1 AND ((`response_sets`.user_id = 1) AND ((completed_at NOT NULL))) LIMIT 1):
EDIT
Using a gem called surveyor. without editing the actual gem, I have to create associating like so in the user model:
has_many :response_sets
has_many :surveys, :through => :response_sets, :conditions => ["completed_at NOT NULL"]
has_many :responses, :through => :response_sets
DB Tables:
I'm pretty sure the syntax is "IS NOT NULL", not just "NOT NULL". I ran a test on my MySQL instance and got an error when I left out the IS
精彩评论