vendredi 16 octobre 2015

Count condition in Where clause using activerecord?

I am making scopes for a model that looks something like this:

class PressRelease < ActiveRecord::Base
  has_many :publications
end

What I want to get is all press_releases that does not have publications, but from a scope method, so it can be chained with other scopes. Any ideas?

Thanks!

NOTE: I know that there are methods like present? or any? and so on, but these methods does not return an ActiveRecord::Relation as scope does.

NOTE: I am using RoR 3

Aucun commentaire:

Enregistrer un commentaire