ActiveRecord, excluding a record !=?
I have the follo开发者_StackOverflow社区wing, which gives me a list of comments:
@comments = record.commentable.comments
record in this case is a comment captured by an observer. What I want to do is get a list of comments excluding the recent comment, which in this case is record.
I tried the following but it errors with
"ActionView::Template::Error (wrong number of arguments (0 for 1)):"
@comments = record.commentable.comments.where(:id != record.id)
Suggestions? thanks
@comments = record.commentable.comments.where('id <> ?' , record.id)
More info here:
- http://asciicasts.com/episodes/215-advanced-queries-in-rails-3
精彩评论