Learn how to use with_scope - a very powerful method which will allow your custom find methods to accept any find options. Just like magic!
# models/task.rb
def self.find_incomplete(options = {})
with_scope :find => options do
find_all_by_complete(false, :order => 'created_at DESC')
end
end
ps: Task.find_incomeplete :limit => 10
本文介绍了一种使用with_scope的方法来增强自定义查找方法的功能,这种方法允许这些方法接受任何查找选项,极大地提高了灵活性和实用性。
2405

被折叠的 条评论
为什么被折叠?



