LeonB schrieb:> Hi!
>
> I have two controllers. Number one has this private method:
>
> private
>
> def clean_balance_cache
> #Expire the cache for the module right
> expire_fragment(:controller => ''application'',
:action => ''balans'')
> end
>
> Is there a way I can call this method in controller #2? I tried adding
> this method to the application helpers. But that didn''t work.
> expire_fragment can''t be used in a helper. It''s an
unknown method
> there.
>
> Thank in advance!
>
>
> >
>
Hi Leon,
just write a small lib, for example
./lib/cache_helper.rb:
# can be used everywhere...
module CacheHelper
def self.expire_balance_cache(controller)
controller.expire_fragment(:controller =>
''application'',
:action => :balance)
end
# or as instance method
def expire_balance_cache
expire_fragment(:controller => ''application'',
:action => :balance)
end
end
./app/controllers/balances_controller.rb
include CacheHelper # unless you want to keep your controller clean
def update
#...
if self.kind_of? CacheHelper
# do this if you included CacheHelper
expire_balance_cache
else
# do this to keep your controller clean
CacheHelper.expire_balance_cache(self)
end
#...
end
Regards
Florian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---