Improvements to the init method in todo_controller to avoid an uneccesary SQL query. Thanks Luke!

Fixes #222.



git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@201 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
bsag 2006-03-04 14:22:04 +00:00
parent c506c00cb7
commit c1a66cf4a9

View file

@ -218,9 +218,7 @@ class TodoController < ApplicationController
@projects = @user.projects
@contexts = @user.contexts
@todos = @user.todos
@done = Todo.find(:all, :conditions => ["todos.user_id = ? and todos.done = ?", @user.id, true], :include => [:project], :order => "completed DESC")
# for some reason, this generates an error about anil object under 0.14.2
#@done = @todos.collect { |x| x.done? ? x:nil }.compact.sort! {|x,y| y.completed <=> x.completed }
@done = @todos.find_all { |x| x.done }
end
end