ActionMailer Question -- can't find email templates


#1

I have a PageController that displays a form. The form is just
straight HTML, I only used the form helpers for the form tag as so:


<%= form_tag({:action => :send_request}, {:method=>:post,
:name=>‘childsplay’})%>

In my page controller I have this:


def send_request
email = InfoMailer::deliver_sendrequest(params)
end

in my action mailer class I have this:
controllers/info_mailer.rb


class InfoMailer < ActionMailer::Base
def sendrequest(formparms)
sent_at = Time.now
@to = ‘removed_email_address@domain.invalid’
@cc = ‘removed_email_address@domain.invalid’
@subject = ‘Thank you for your request’
@recipients = ‘’
@from = ‘removed_email_address@domain.invalid’
@sent_on = sent_at
@headers = {}

@body['name'] = formparms[:from_name]

end
end

The error I get is this:

ActionView::ActionViewError in Page#send_request

No rhtml, rxml, or delegate template found for sendrequest.rhtml

I REALLY DO have a a rhtml file at views/info_mailer/sendrequest.rhtml

it contains the following:


Dear <%=@from_name %>,

Thank you for your request, we will respond shortly!

Any ideas? … when I assign a body the message I want to send:

def sendrequest(formparms)
sent_at = Time.now
@to = ‘removed_email_address@domain.invalid’
@cc = ‘removed_email_address@domain.invalid’
@subject = ‘Thank you for your request’

@recipients = ''
@from       = 'removed_email_address@domain.invalid'
@sent_on    = sent_at
@headers    = {}

#@body = ‘Thank you, the request is being processed’
end

That works ok, it just doesn’t seem to be finding the template. What
am I doing wrong??


http://PhpGirl.blogger.com
http://CodeSnipers.com


#2

Nola S. wrote:

def send_request
email = InfoMailer::deliver_sendrequest(params)
end

in my action mailer class I have this:
controllers/info_mailer.rb

Mailers are usually put in the models directory, and
their deliver methods are usually called as class methods
using the dot notation, rather than with the :: notation.


We develop, watch us RoR, in numbers too big to ignore.