在我编写更好的模型方法的微弱尝试中,我失败了。这反过来又让我在这里问我的问题。
这是我的模型:
class Group < ActiveRecord::Base
# Because of inheritance issues with ActiveRecord
# We tell this Relation to use a "false" column to persuade
# The relation to push forward without worrying about Inheritance
self.inheritance_column = :_type_disabled
scope :expired?, where('expiration_date > ?', Time.now)
end
这就是我试图用我的scope
g = Group.find(91)
g.expired?
所以,基本上看看我是否可以判断该组是否已过期。现在,我知道我可以在我的控制器中的 activerecord where 语句中写这个,但我试图更好地理解处理模型中的数据Rails