instance method uncacheable!

Ruby on Rails 7.1.6

Since v7.0.10

Available in: v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

uncacheable!()

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 %>
Source
# File actionview/lib/action_view/helpers/cache_helper.rb, line 205
      def uncacheable!
        raise UncacheableFragmentError, "can't be fragment cached" if caching?
      end

Defined in actionview/lib/action_view/helpers/cache_helper.rb line 205 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionView::Helpers::CacheHelper

Type at least 2 characters to search.

↑↓ navigate · open · esc close