鉴于@comments - 如何排除第一条记录

问题描述:

给出@comments = Comments.last(6),该查询基于该模型的默认命名的范围。鉴于@comments - 如何排除第一条记录

我怎么能告诉实质上对Rails给我最后的6条排除了第一个记录?
如果有小于6,只要给我尽可能多的高达6越好,再次排除了第一个记录?

感谢

class Comment < ActiveRecord::Base 
    scope :excluding_first, lambda { 
    first = Comment.first 
    return [] unless first 
    where("id <> #{first.id}") 
    } 
end 

由于示波器组成,你可以再做:

Comment.excluding_first.last(6) 

我可能会使用暴力,而不是SQL的魔法在这里:

@comments.delete_at(0)