Dynamic find_by Methods

下面是一个查找未完成的任务的model:
class TaskController < ApplicationController  
    def incomplete  
        @tasks = Task.find(:all, :conditions => ['complete = ?', false])  
    end  
  
    def last_incomplete   
        @task = Task.find(:first, :conditions => ['complete =?', false], :order => 'created_at DESC')  
    end  
end  

用find_by可以更优雅的实现:
class TaskController < ApplicationController  
    def incomplete  
       @tasks = Task.find_all_by_complete(false)    
    end  
  
    def last_incomplete   
        @task = Task.find_by_complete(false, :order => 'created_at DESC')   
    end  
end  



find_by方法带order参数和find方法的一样。

    怎么发论坛来了。。搞错了....................
为什么发到论坛的东西自己删不掉呢?这不合理






你可能感兴趣的:(JavaScript,应用服务器,Ruby,ActiveRecord,Rails)