Hi all, Is it possible to use expire_action in a model? I tried: after_save :clean_balance_cache clean_balance_cache holds the expire_action method. But then I get an error: undefined method `expire_action'' for #<Declaration:0xb69d19b0> Is there a way to make this work? Or should I make it work another way? Thanks in advance! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I don''t know if it''s possible (you might be able to use ''include ActionController::Caching::Actions'' in the model) but I prefer my cache expiration to be outside of the model and in sweeper files.. class DeclarationSweeper < ActionController::Caching::Sweeper observe Declaration def after_create(page) # expire something... end end Leon Bogaert wrote:> Hi all, > > Is it possible to use expire_action in a model? > I tried: > after_save :clean_balance_cache > > clean_balance_cache holds the expire_action method. But then I get an > error: > undefined method `expire_action'' for #<Declaration:0xb69d19b0> > > Is there a way to make this work? Or should I make it work another way? > > Thanks in advance! > -- > Posted via http://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
idleFingers wrote:> I don''t know if it''s possible (you might be able to use ''include > ActionController::Caching::Actions'' in the model) but I prefer my > cache expiration to be outside of the model and in sweeper files.. > > class DeclarationSweeper < ActionController::Caching::Sweeper > > observe Declaration > > def after_create(page) > # expire something... > end > > endThanks. But the cache I want to sweep is based on the data of two different models. Is it possible to call the same method (clean_balance_cache) in two different sweeper files? The method consists of `expire_action'' and some other things. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Leon Bogaert wrote:> idleFingers wrote: >> I don''t know if it''s possible (you might be able to use ''include >> ActionController::Caching::Actions'' in the model) but I prefer my >> cache expiration to be outside of the model and in sweeper files.. >> >> class DeclarationSweeper < ActionController::Caching::Sweeper >> >> observe Declaration >> >> def after_create(page) >> # expire something... >> end >> >> end > > Thanks. But the cache I want to sweep is based on the data of two > different models. Is it possible to call the same method > (clean_balance_cache) in two different sweeper files? The method > consists of `expire_action'' and some other things.This worked: class BalanceSweeper < ActionController::Caching::Sweeper observe Declaration, Deposit def after_create(data) clean_balance_cache end def after_save(data) clean_balance_cache end def after_destroy(data) end def clean_balance_cache #Expire the cache for the module right #expire_fragment(:controller => ''application'', :action => ''balans'') expire_action :controller => ''ajax'', :action => ''module_balans'' end end Thanks! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---