| Module | ConditionalFragmentCaching::ActionController |
| In: |
lib/fragment_caching.rb
|
A method for checking if a cached fragment exists when a certain condition is true. The first parameter is that condition, the rest are the normal parameters for ActionController::Caching::Fragments.read_fragment
A default call, the equivalent of read_fragment()
if conditional_read_fragment(@current_user.nil?)
# code that should not be run if there's a cache
end
Passing additional caching params works in the same way
if conditional_read_fragment(@current_user.nil?, :page => params[:page])
# ...
end
# File lib/fragment_caching.rb, line 29
29: def conditional_read_fragment(conditional, name={}, options = nil)
30: return read_fragment(name, options) if conditional
31: end