I have 3 models
City.rb
has_many :places
Place.rb
has_many :reviews, as: :reviewable
And Reviews which have an attribute state which I would like to be able to check.
Review.rb
belongs_to :reviewable, polymorphic: true
state_machine :initial => :draft do #etc.
I would like to be able to call City.find("somecity").places
and instead of showing all places, replace the default scope to find only places which have a review with the state of "published"
In activerecord something like...
City.find("somecity").places.where('reviews.state' => 'published')
Is there any way to do this in mongoid or my second option would be to incorporate a new attribute into places which gets set to active whenever a review is published.