Justin Britten wrote:
> The problem is that the model object doesn't seem to be available to the 
> callback function.
> 
> For example, in the sweeper:
> observe MyModel
> 
> def after_create(record)
>   expire the cache
> end
> 
> And, in the BackgroundRB worker:
> MyModel.create()
> 
> And when the BackgroundRB async task is started, the MyModel 
> after_create() method is invoked as expected; however, record is nil (as 
> is self).
> 
> The record has some info in it that I use to calculate the path to 
> expire.  So, I can't call Rails.cache.delete(cache_path) when I can't 
> determine the value of cache_path.
> 
> Thanks for taking the time to help,
> Justin

If there's something wrong with BackgroundRB and sweepers, have you 
tried:

In the BackgroundRB worker:

  my_model = MyModel.create(blah blah blah)
  my_model.clear_the_cache

and inside MyModel

  def clear_the_cache
    Rails.cache.clear(cache_path from data)
  end

AR.create *should* be handing back a model, which could self-inspect to 
derive the cache path to expire...

-- 
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to