Forum: Ruby on Rails Fragment Cache in ActionMailer

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4d47944ad8359101bccb0a798cd9acf1?d=identicon&s=25 Hugh (Guest)
on 2007-01-25 17:33
(Received via mailing list)
I have a controller which iterates through a group of people and
dynamically generates an email for each person, it is a bit DB heavy so
caching would really help.

Adding 'include ActionController::Caching::Fragments' to my
BookingMailer model produces this error:

ActionView::TemplateError (undefined local variable or method
`perform_caching' for #<BookingMailer:0x4768834>)

So I added 'include ActionController::Caching' as well. Now I get:

ActionView::TemplateError (undefined method `url_for' for
#<BookingMailer:0x4894398>)

I'm using :part => to store each individual booking div as a cache so I
see how a model doesn't know about 'url_for'. Finally I added a third
include 'include ActionController::Base' but my last error is:

TypeError (wrong argument type Class (expected Module)):

Any help would be appreciated, I'm really stuck on this one, my cache
code is this:

<% cache(:controller => 'job', :action => 'open_request_for_jobs',
:part => 'job_' + j.id.to_s) do -%>
  ... details about the job .....
<% end %>

Thanks,
Hugh
This topic is locked and can not be replied to.