I am implementing user setting in my rails website where a user has control over who can send him notifications. The allowed classed of users who can send him information is stored in an array and can be set by the user.
How do I query users to send the notification according to the user type of the user who sent the post.
I want to do something like this.
notifiable_users = User.all.or("notification_setting.posted_by" includes "sender.user_type")
all.orsupposed to mean?Model.all.where(...)andModel.where(...), butoris not a model method and only works for criteria, so it is necessary to doModel.all.or(...). Now on to filtering objects in memory, that is not the case, mongoid creates query using the criteria objects and evaluates them lazily. So, it doesn't ask DB for results until you use some method on criteria which can not be chained to add to the query. refer to mongoid.org/docs/querying/criteria.html for details.any_ofthere, notor, where is it defined? Also in ActiveRecord, and I fear, it's the same in Mongoid doing.alltriggers the call directly.Model.scopedis then preferred.