简体   繁体   English

rails for mysql2 gem for .include?

[英]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 使用ubuntu 10.04,rails 3.0.7,ruby 1.9.2和mysql2 gem

what am I doing wrong? 我究竟做错了什么?

haml view: haml视图:

- 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_sets`.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: 在不编辑实际gem的情况下,我必须在用户模型中创建如此关联:

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". 我很确定语法是“IS NOT NULL”,而不仅仅是“NOT NULL”。 I ran a test on my MySQL instance and got an error when I left out the IS 我在我的MySQL实例上运行了一个测试,当我遗漏了IS时出错了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM