@@ -10,23 +10,23 @@ module Caching
10
10
# <%= render :partial => "topic", :collection => Topic.find(:all) %>
11
11
# <% end %>
12
12
#
13
- # This cache will bind to the name of the action that called it, so if this code was part of the view for the topics/list action, you would
14
- # be able to invalidate it using <tt>expire_fragment(:controller => "topics", :action => "list")</tt>.
15
- #
16
- # This default behavior is of limited use if you need to cache multiple fragments per action or if the action itself is cached using
13
+ # This cache will bind to the name of the action that called it, so if this code was part of the view for the topics/list action, you would
14
+ # be able to invalidate it using <tt>expire_fragment(:controller => "topics", :action => "list")</tt>.
15
+ #
16
+ # This default behavior is of limited use if you need to cache multiple fragments per action or if the action itself is cached using
17
17
# <tt>caches_action</tt>, so we also have the option to qualify the name of the cached fragment with something like:
18
18
#
19
19
# <% cache(:action => "list", :action_suffix => "all_topics") do %>
20
20
#
21
- # That would result in a name such as "/topics/list/all_topics", avoiding conflicts with the action cache and with any fragments that use a
22
- # different suffix. Note that the URL doesn't have to really exist or be callable - the url_for system is just used to generate unique
23
- # cache names that we can refer to when we need to expire the cache.
24
- #
21
+ # That would result in a name such as "/topics/list/all_topics", avoiding conflicts with the action cache and with any fragments that use a
22
+ # different suffix. Note that the URL doesn't have to really exist or be callable - the url_for system is just used to generate unique
23
+ # cache names that we can refer to when we need to expire the cache.
24
+ #
25
25
# The expiration call for this example is:
26
- #
26
+ #
27
27
# expire_fragment(:controller => "topics", :action => "list", :action_suffix => "all_topics")
28
28
module Fragments
29
- # Given a key (as described in <tt>expire_fragment</tt>), returns a key suitable for use in reading,
29
+ # Given a key (as described in <tt>expire_fragment</tt>), returns a key suitable for use in reading,
30
30
# writing, or expiring a cached fragment. If the key is a hash, the generated key is the return
31
31
# value of url_for on that hash (without the protocol). All keys are prefixed with "views/" and uses
32
32
# ActiveSupport::Cache.expand_cache_key for the expansion.
@@ -50,7 +50,7 @@ def fragment_for(buffer, name = {}, options = nil, &block) #:nodoc:
50
50
51
51
# Writes <tt>content</tt> to the location signified by <tt>key</tt> (see <tt>expire_fragment</tt> for acceptable formats)
52
52
def write_fragment ( key , content , options = nil )
53
- return unless cache_configured?
53
+ return content unless cache_configured?
54
54
55
55
key = fragment_cache_key ( key )
56
56
0 commit comments