Method: ActionView::Helpers::CacheHelper#uncacheable!
- Defined in:
- actionview/lib/action_view/helpers/cache_helper.rb
#uncacheable! ⇒ Object
Raises UncacheableFragmentError when called from within a cache
block.
Useful to denote helper methods that can’t participate in fragment caching:
def project_name_with_time(project)
uncacheable!
"#{project.name} - #{Time.now}"
end
# Which will then raise if used within a `cache` block:
<% cache project do %>
<%= project_name_with_time(project) %>
<% end %>
213 214 215 |
# File 'actionview/lib/action_view/helpers/cache_helper.rb', line 213 def uncacheable! raise UncacheableFragmentError, "can't be fragment cached" if caching? end |