I have the next models, using Mongoid:
class Album
have_many :images
end
class Image
belongs_to :album
end
I want to get only albums that have any images:
Album.all.select{ |a| a.images.count > 0 }
But it return an array and I need a Mongoid::Criteria. I tried using something like:
Album.where( "this.images.count > 0" )
and it always return 0 elements. ¿ How can I do it ?