ruby on rails - Calling controller method from a helper module -


using rails 3.2

i'm trying call expire_fragment, rails view method, helper getting error:

undefined method `expire_fragment' #<#<class:0x00000118977110>:0x00000103b853b8> 

i'm trying conditionally clear cache. helper method call in view

clear_cache_keys_if(params[:cc], [@product, :search_filters]) 

and in helper

  def clear_cache_keys_if(condition, keys = [])     if condition       keys.each |key|         expire_fragment(key)       end     end   end 

i have thought rails fragment caching methods accessible in helper module, doesn't seem case.

i changed

controller.expire_fragment(key)  

and worked.

this method available in view. it's available controller. don't understand why not available in helper. missing here? why isn't available in helper , best way expose it? thanks


Comments