- 论坛徽章:
- 0
|
class Project ['project_id = ? and complete = ?', @project.id, false])
end
end
This is the stupid way doing this job, let try to find a smarter way to do this, using the association between project and task model.
def show
@tasks = @project.tasks.find(:all, :conditions => ['complete = ?', false])
end
or, even better way:
def show
@tasks = @project.tasks.find_all_by_complete(false)
end
That's to say, project_id can be removed from the query conditions, since it is in the mean of the associations.
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/25407/showart_1902626.html |
|