fix caching for #1328 and #1329

This commit is contained in:
Reinier Balt 2012-09-19 17:13:29 +02:00
parent b89062913f
commit b3059cf53a
3 changed files with 11 additions and 4 deletions

View file

@ -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

View file

@ -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
%>
<div id="c<%= context.id %>" class="container context" style="display:<%= (collapsible && @not_done.empty?) ? "none" : "block" %>">
<h2>

View file

@ -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 %>
<div class="container">
<h2 id="project_name_container">
<% if collapsible -%>