`
CaiDeHen
  • 浏览: 90500 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

#5 Using with_scope

阅读更多
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
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics