I am trying to understand the following behaviour of the ActionMailer
in Rails 2.
I have an emailer_controller.rb
class EmailerController < ApplicationController
I have a model emailer.rb
class Emailer < ActionMailer::Base
def contact_email(email_params, sent_at = Time.now)
@recipients = “email@example.com”
@from = email_params[:name] + " <" + email_params[:address] +
@subject = email_params[:subject]
@sent_on = sent_at
@body[“email_body”] = email_params[:body]
@body[“email_name”] = email_params[:name]
and I send from within a form
<%= form_tag :action=> “send_mail”, :controller=> “emailer” %>
… some details deleted here …
and I have a send_mail.html.erb template with some content (thanx for
In this setup I get an error: Missing template emailer/
When I add an empty template of that name, everything works nicely.
My question is: WHY do I need a template with the same name as a
method in the model? So far as I understand Ruby, I am expected to
have a template for the controller method - but why for the model.
And: If I put some content into that file it is not displayed.
So: What happens with the content in emailer/contact_email.html.erb ?
Thanx for helping out.