【发布时间】:2023-03-14 08:56:01
【问题描述】:
如何在命名范围内使用脏对象?
这个 named_scope 工作正常。
named_scope :recently_tested, lambda{|test_id|
{
:conditions => ["test_id = ? and status = ?",test_id,PUBLISHED],
:order => "updated_at DESC"
}
}
我想加强它。像
named_scope :recently_tested, lambda{|test_id|
{
:conditions => ["test_id = ? and status = ? and status_was = ?",test_id,PUBLISHED,PUBLISHED],
:order => "updated_at DESC"
}
}
是否可以在 named_scope 中使用脏对象?还有其他方法来处理这种情况吗?
【问题讨论】:
标签: mysql ruby-on-rails ruby