#tasks_controller.rb
def index
@tasks = Task.find_incomplete
end
#--------------------------------
#models/task.rb
def self.find_incomplete
find_all_by_complete(false, :order => 'created_at DESC')
end
#--------------------------------
#projects_controller.rb
def show
@project = Project.find(params[:id])
@tasks = @project.tasks.find_incomplete
end
转载于:https://my.oschina.net/themorecolor/blog/129086