引数に含まないレコードを返す

Lokkaのactiverecordブランチ(次期master)に
without_selfというscopeがあったんだけど、postgresqlじゃ動かなかった。

  scope :without_self,                                                                                                                                                
    ->(id){ self.where('id IS NOT ?', id) }

これで動いた。

  scope :without_self,
    ->(id){ self.where("id not in (?)", id) }

Rails4からはRelation#notがあって、完全にラッピングしてくれるのでこういう事故が起きないと思う。
http://tech.actindi.net/3595022147