Using Rails 3, is it possible to detect to see inside of the layout or a before_filter to see if an action is going to be cached and if there is a cache hit for that action?
caches_index :something, :layout => false
So for example (inside application.html.erb)
<%= yield %>
<% @is_cached == ... %>
Is it possible to do it before and/or after yield call to the item?
I'm using fragment caching this way:
#helper
def cache_unless(condition, name = {}, &block)
unless condition
cache(name, &block)
else
yield
end
end
#view
<% cache_unless has_permission?, :action => :index, :folder => @folder, :user_id => @user.id do %>
...
<% end %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With