diff options
author | Yehuda Katz <wycats@gmail.com> | 2009-08-14 12:00:52 -0700 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2009-08-15 12:32:01 -0700 |
commit | 9b552fb300c4606fe517eadaa30708e9d75498a6 (patch) | |
tree | bdf53599767b72628e5ce49fa701cd953c69175c /actionpack/lib/abstract_controller | |
parent | 9f5cd0156ab907d8097fc9c588823a9b09038b93 (diff) | |
download | rails-9b552fb300c4606fe517eadaa30708e9d75498a6.tar.gz rails-9b552fb300c4606fe517eadaa30708e9d75498a6.tar.bz2 rails-9b552fb300c4606fe517eadaa30708e9d75498a6.zip |
Caches and cache clearing seems to actually work, but the actual architecture is kind of messy. Next: CLEAN UP.
Diffstat (limited to 'actionpack/lib/abstract_controller')
-rw-r--r-- | actionpack/lib/abstract_controller/layouts.rb | 13 | ||||
-rw-r--r-- | actionpack/lib/abstract_controller/rendering_controller.rb | 17 |
2 files changed, 23 insertions, 7 deletions
diff --git a/actionpack/lib/abstract_controller/layouts.rb b/actionpack/lib/abstract_controller/layouts.rb index ac2154dffc..a8bd2b80e1 100644 --- a/actionpack/lib/abstract_controller/layouts.rb +++ b/actionpack/lib/abstract_controller/layouts.rb @@ -19,15 +19,20 @@ module AbstractController end end + def clear_template_caches! + @found_layouts.clear if @found_layouts + super + end + def cache_layout(details) layout = @found_layouts - values = details.values_at(:formats, :locale) + key = Thread.current[:format_locale_key] # Cache nil - if layout.key?(values) - return layout[values] + if layout.key?(key) + return layout[key] else - layout[values] = yield + layout[key] = yield end end diff --git a/actionpack/lib/abstract_controller/rendering_controller.rb b/actionpack/lib/abstract_controller/rendering_controller.rb index bb7891fbfd..feca1bc4b7 100644 --- a/actionpack/lib/abstract_controller/rendering_controller.rb +++ b/actionpack/lib/abstract_controller/rendering_controller.rb @@ -111,12 +111,21 @@ module AbstractController def _determine_template(options) name = (options[:_template_name] || action_name).to_s - options[:_template] ||= view_paths.find( - name, { :formats => formats }, options[:_prefix], options[:_partial] - ) + options[:_template] ||= with_template_cache(name) do + view_paths.find( + name, { :formats => formats }, options[:_prefix], options[:_partial] + ) + end + end + + def with_template_cache(name) + yield end module ClassMethods + def clear_template_caches! + end + # Append a path to the list of view paths for this controller. # # ==== Parameters @@ -134,6 +143,7 @@ module AbstractController # the default view path. You may also provide a custom view path # (see ActionView::ViewPathSet for more information) def prepend_view_path(path) + clear_template_caches! self.view_paths.unshift(path) end @@ -148,6 +158,7 @@ module AbstractController # paths<ViewPathSet, Object>:: If a ViewPathSet is provided, use that; # otherwise, process the parameter into a ViewPathSet. def view_paths=(paths) + clear_template_caches! self._view_paths = paths.is_a?(ActionView::PathSet) ? paths : ActionView::Base.process_view_paths(paths) end |