嘿我正试图找到一种方法来过滤我的帖子记录。我只想显示不比前天更早的记录。我想出了这行代码,
Post.where(:course_id => current_user.courses & :date > (Date.yesterday-1))
但我收到此错误:can't convert Symbol into Array
你的时间
答案 0 :(得分:9)
您不能在多个哈希项之间使用&符号,并且必须使用字符串来执行少于,大于等的任何操作。
Post.where("course_id in (?) and date > ?", current_user.courses, Date.yesterday - 1)