diff --git a/tracks/app/controllers/todo_controller.rb b/tracks/app/controllers/todo_controller.rb index 04179a68..0a6068a9 100644 --- a/tracks/app/controllers/todo_controller.rb +++ b/tracks/app/controllers/todo_controller.rb @@ -139,6 +139,9 @@ class TodoController < ApplicationController @projects = @user.projects @contexts = @user.contexts @todos = @user.todos - @done = @todos.collect { |x| x.done? ? x:nil }.compact.sort! {|x,y| y.completed <=> x.completed } + @done = Todo.find(:all, :conditions => ["todos.user_id = ? and todos.done = 1", @user.id], :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 } + end end diff --git a/tracks/app/models/context.rb b/tracks/app/models/context.rb index 30caafbb..67b1483b 100644 --- a/tracks/app/models/context.rb +++ b/tracks/app/models/context.rb @@ -17,12 +17,14 @@ class Context < ActiveRecord::Base end def find_not_done_todos - todos = Todo.find :all, :conditions => "context_id = #{id} AND done = 0", + todos = Todo.find :all, :conditions => "todos.context_id = #{id} AND todos.done = 0", + :include => [:context, :project], :order => "due IS NULL, due ASC, created_at ASC" end def find_done_todos - todos = Todo.find :all, :conditions => "context_id = #{id} AND done = 1", + todos = Todo.find :all, :conditions => "todos.context_id = #{id} AND todos.done = 1", + :include => [:context, :project], :order => "due IS NULL, due ASC, created_at ASC" end diff --git a/tracks/config/environment.rb b/tracks/config/environment.rb index 8d879ef3..620155e5 100644 --- a/tracks/config/environment.rb +++ b/tracks/config/environment.rb @@ -1,6 +1,6 @@ # Be sure to restart your webserver when you modify this file. - # Uncomment below to force Rails into production mode + # (Use only when you can't set environment variables through your web/app server) # ENV['RAILS_ENV'] = 'production'