How to have multiple conditions in a named scope?

后端 未结 3 1650
南方客
南方客 2020-12-18 04:58

I have a User model. I can check whether a User is an admin by doing a_user.try(:admin?).

I\'d like to define a named scope that gets all Users updated

3条回答
  •  醉梦人生
    2020-12-18 05:36

    if admin column in users table is a boolean,

    scope :recent, lambda { :conditions => ['updated_at > ? AND admin != ?', 5.minutes.ago, true] }
    

提交回复
热议问题