Same .rhtml and partial in mailer and non-mailer contexts

I have an ActionMailer template that properly generates HTML email. It
contains a partial.

The mail action was called via the following in my controller:

def cmasend
@cmaform = Cmaform.find(params[:id])
flash[:notice] = ‘CMA Sent.’
redirect_to :action => ‘list’

Then, in order to allow a “preview” of the message in a browser, I found
that if I called Mailer.create_cma(obj), the body was quoted-printable
and not readily displayable in a browser, so I rendered it from my
controller as follows:

def cmapreview
@cmaform = Cmaform.find(params[:id])
render :template => “mailer/cma.text.html.rhtml”, :id => @cmaform

However, when I did this, the partial called by the template couldn’t be
found. So I modified the render(:partial … ) call in my temmplate to
set the path to the partial _comp.rhtml as follows:

<%= render(:partial => “mailer/comp”, :object => @cmacomp,
:locals => {:cmacomp => @cmacomp}) %>

This worked with my preview, but it does not work with the
Mailer.deliver method. The error message is the somewhat unhelpful "“No
rhtml, rxml, rjs or delegate template found”.

Is there an elegant way to get this Mailer template and its partial to
render properly when called by a Mailer method /and/ from another
controller’s render()?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs