这在本地工作,但不适用于生产服务器。
使用ubuntu 10.04,rails 3.0.7,ruby 1.9.2和mysql2 gem
我究竟做错了什么?
雾视图:
- unless current_user.surveys.include?(survey)
退货
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_sets`.survey_id WHERE `surveys`.`id` = 1 AND ((`response_sets`.user_id = 1) AND ((completed_at NOT NULL))) LIMIT 1):
编辑
使用一种称为测量员的宝石。在不编辑实际gem的情况下,我必须像在用户模型中那样创建关联:
has_many :response_sets
has_many :surveys, :through => :response_sets, :conditions => ["completed_at NOT NULL"]
has_many :responses, :through => :response_sets
数据库表:
最佳答案
我很确定语法是“ IS NOT NULL”,而不仅仅是“ NOT NULL”。我在MySQL实例上进行了测试,但忽略了IS