scope cached fragments to locale, fix some caching issues

Change-Id: Id1ad5229bbde6f54bf8b8b92030bb69180bef5b6
Reviewed-on: https://gerrit.instructure.com/4933
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
This commit is contained in:
Jon Jensen 2011-08-04 10:28:36 -06:00
parent 043c92e575
commit 103116eadf
3 changed files with 11 additions and 3 deletions

View File

@ -272,7 +272,7 @@ var I18n = I18n || {};
def section_tabs
@section_tabs ||= begin
if @context
Rails.cache.fetch([@context, @current_user, "section_tabs"].cache_key) do
Rails.cache.fetch([@context, @current_user, "section_tabs", I18n.locale].cache_key) do
if @context.respond_to?(:tabs_available) && !@context.tabs_available(@current_user).empty?
html = []
html << '<nav role="navigation"><ul id="section-tabs">'
@ -447,4 +447,12 @@ var I18n = I18n || {};
def join_title(*parts)
parts.join(t('#title_separator', ': '))
end
def cache(name = {}, options = nil, &block)
unless options && options[:no_locale]
name = name.cache_key if name.respond_to?(:cache_key)
name = name + "/#{I18n.locale}" if name.is_a?(String)
end
super
end
end

View File

@ -74,7 +74,7 @@
<% end %>
<div style="display: none;" id="context_urls">
<% @contexts.each do |context| %>
<% cache(context, 'assignment_groups_for_cal') do %>
<% cache([context, 'assignment_groups_for_cal']) do %>
<a href="<%= context_url(context, :context_calendar_events_url) %>" class="<%= context.class.to_s.downcase %>_<%= context.id %>_add_event_url">&nbsp;</a>
<a href="<%= context_url(context, :context_calendar_event_url, "{{ id }}") %>" class="<%= context.class.to_s.downcase %>_<%= context.id %>_event_url">&nbsp;</a>
<% if context.respond_to?("assignments") %>

View File

@ -303,7 +303,7 @@ TEXT
<% if can_do(@context, @current_user, :manage_grades) %>
<div style="display: none;" id="progression_list">
<a href="#" class="progression_list_url">&nbsp;</a>
<% cache([@context, @current_user, 'students_visible_to_user'].cache_key) do %>
<% cache([@context, @current_user, 'students_visible_to_user'].cache_key, :no_locale => true) do %>
<% @context.students_visible_to(@current_user).scoped(:select => "id, name").each do |student| %>
<div class="student student_<%= student.id %>">
<div class="id"><%= student.id %></div>