#3 Find Through Association

296 ワード

No need to pass foreign keys in find conditions, just do the find through a has_many association.

# projects_controller.rb
def show
  @project = Project.find(params[:id])
  @tasks = @project.tasks.find_all_by_complete(false)
end