I have the following piece of code that's broken:
//user_posts_id is an array of integer values @comment_notifications = Comment.where(["author_id != ? and post_id in ?", current_user.id, user_posts_id]) This is part of the error:
PG::SyntaxError: ERROR: syntax error at or near "1" LINE 1: ... "comments" WHERE (author_id != 8 and post_id in 1,4,8,9,2,... ^ : SELECT "comments".* FROM "comments" WHERE (author_id != 8 and post_id in 1,4,8,9,2,3)
It doesn't seem to work because of the second conditional for "posts_id" and "user_posts_id". Also the "!=" complicates things a little, I think. What would be the appropriate way to write this ActiveRecord query?
Appreciate any suggestions! Thanks.