0
我正在使用Rails 4并具有notifs
和users
模型。Rails使用自定义模型方法
每个notif
has_many
users
(又名哪个user
已见过notif
)。我试图获得所有没有被current_user
看到的通知。为了检查current_user
已经看到了通知符我使用这个模型类:
def seen_by?(u)
return self.users.include?(u)
end
如何使用一个电话来获取所有notifs其中seen_by(current_user)
是true
?
喜欢的东西:
Notif.where(seen_by(current_user): true)