From b3059cf53ac5949a319a957d9f4b400fb244e9c6 Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Wed, 19 Sep 2012 17:13:29 +0200 Subject: [PATCH] fix caching for #1328 and #1329 --- app/models/dependency.rb | 6 ++++-- app/views/contexts/_context.html.erb | 4 +++- app/views/projects/_project.html.erb | 5 ++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/models/dependency.rb b/app/models/dependency.rb index dd347c1f..a55308d3 100644 --- a/app/models/dependency.rb +++ b/app/models/dependency.rb @@ -1,7 +1,9 @@ class Dependency < ActiveRecord::Base - belongs_to :predecessor, :foreign_key => 'predecessor_id', :class_name => 'Todo' - belongs_to :successor, :foreign_key => 'successor_id', :class_name => 'Todo' + # touch to make sure todo caches for predecessor and successor are invalidated + + belongs_to :predecessor, :foreign_key => 'predecessor_id', :class_name => 'Todo', :touch => true + belongs_to :successor, :foreign_key => 'successor_id', :class_name => 'Todo', :touch => true end diff --git a/app/views/contexts/_context.html.erb b/app/views/contexts/_context.html.erb index e8221951..f6b940c9 100644 --- a/app/views/contexts/_context.html.erb +++ b/app/views/contexts/_context.html.erb @@ -1,6 +1,8 @@ <% @not_done = @not_done_todos.select {|t| t.context_id == context.id } -cache [context, @source_view] do +# invalidate the cache every day because of staleness or +# rendering of "due in x days" that change without touching updated at of the todo +cache [context, @source_view, current_user.date.strftime("%Y%m%d")] do %>
">

diff --git a/app/views/projects/_project.html.erb b/app/views/projects/_project.html.erb index 1f1b68ca..0f93bd8f 100644 --- a/app/views/projects/_project.html.erb +++ b/app/views/projects/_project.html.erb @@ -1,4 +1,7 @@ -<% cache project do %> +<% +# invalidate the cache every day because of staleness or +# rendering of "due in x days" that change without touching updated at of the todo +cache [project, current_user.date.strftime("%Y%m%d")] do %>

<% if collapsible -%>