Dear all,

I am trying to understand the following behaviour of the ActionMailer
in Rails 2.

I have an emailer_controller.rb

class EmailerController < ApplicationController
  def send_mail
      Emailer::deliver_contact_email(params[:email])
  end
end

I have a model emailer.rb

class Emailer < ActionMailer::Base
    def contact_email(email_params, sent_at = Time.now)
        @recipients = "[EMAIL PROTECTED]"
        @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]
    end
end

and I send from within a form

<%= form_tag :action=> "send_mail", :controller=> "emailer" %>
  ... some details deleted here ...
    <input type="submit" value="Send" class="primary" />
  <%=  %>

and I have a send_mail.html.erb template with some content (thanx for
your mail...)

In this setup I get an error:  Missing template emailer/
contact_email.html.erb

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.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to