How to expire fragment cache from model?

Hi. I need to figure out how to call expire_fragment from within a
model. Seems to be a method which is not normally available to the
model…?

Situation is that I am feeding emails in via a MailReceiver model:

class MyMailReceiver < ActionMailer::Base
etc ...

I’m using an external script to call something like “script/runner
MyMailReceiver.receive(somedata)”, and as a result of this call I need
to then expire some page fragment cache items

Any suggestions on how to make this happen? Should perhaps I not be
pushing my email directly into the Model and instead via some
controller…? Any other suggestions for how to accept external email
into Rails?

Cheers

Ed W

Ed Wg wrote:

Hi. I need to figure out how to call expire_fragment from within a
model. Seems to be a method which is not normally available to the
model…?

Situation is that I am feeding emails in via a MailReceiver model:

class MyMailReceiver < ActionMailer::Base
etc ...

I’m using an external script to call something like “script/runner
MyMailReceiver.receive(somedata)”, and as a result of this call I need
to then expire some page fragment cache items

Any suggestions on how to make this happen? Should perhaps I not be
pushing my email directly into the Model and instead via some
controller…? Any other suggestions for how to accept external email
into Rails?

Cheers

Ed W

try:

include ActionController::Caching::Fragments

Long shot, but who knows. It’s probably better to include this in your
script than the model itself, since the model itself should not know
about caching.

try:

include ActionController::Caching::Fragments

Long shot, but who knows. It’s probably better to include this in your
script than the model itself, since the model itself should not know
about caching.

Seems like the better thing is for the script to call a controller
rather than a model directly?

The example on the rails wiki talks directly to the model, but I think
this feels like a bit of a hack really…

Appreciate any thoughts…

Cheers

Ed W