Eliminated double UPDATE when marking actions done or not done. Eliminated query for count of complete Todos in cases where it is not used.

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@658 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
lukemelia 2007-11-26 02:58:21 +00:00
parent bfb51dd472
commit b16ff933cb
2 changed files with 6 additions and 5 deletions

View file

@ -106,14 +106,13 @@ class TodosController < ApplicationController
# Toggles the 'done' status of the action
#
def toggle_check
@todo.toggle_completion!
@saved = @todo.save
@saved = @todo.toggle_completion!
respond_to do |format|
format.js do
if @saved
determine_remaining_in_context_count(@todo.context_id)
determine_down_count
determine_completed_count
determine_completed_count if @todo.completed?
end
render
end

View file

@ -51,11 +51,13 @@ class Todo < ActiveRecord::Base
end
def toggle_completion!
saved = false
if completed?
activate!
saved = activate!
else
complete!
saved = complete!
end
return saved
end
def activate_and_save!