开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜