Ok, I just cant seem to understand this. I have an ActionMailer model:
class Emailer < ActionMailer::Base
def contact(recipient, subject, message, returnadd, sent_at =
Time.now)
@subject = subject
@recipients = recipient
@from = returnadd
@sent_on = sent_at
@body[“title”] = ‘This is title’
@body[“email”] = ‘[email protected]’
@body[“message”] = message
@headers = {}
# repl last line and use below to send html email if not set
in /environments/*.rb file:
# @headers = {content_type => ‘text/html’}
end
end
I have a form to implement the model:
Send Email
<% form_remote_tag :update => 'contaner', :url => {:controller => 'emailer', :action => 'sendmail'}, :html => {:name => 'form'+(params [:id]).to_s} do %>Subject: <%= text_field 'email', 'subject' %>
Recipient: <%= text_field 'email', 'recipient', :readonly => 'true' %>
Message
<%= text_area 'email', 'message' %>
When ‘Submit’ is clicked, it invokes the sendmail functino in my
EmailerController:
class EmailerController < ApplicationController
def sendmail
recipient = params[:email][:recipient]
subject = params[:email][:subject]
message = params[:email][:message]
returnadd = current_associate.email
mymail = Emailer.create_contact(recipient, subject, message,
returnadd)
Emailer.deliver(mymail);
end
end
Which SHOULD then render by /views/emailer/sendmail.erb
Message Sent!<%= link_to "Continue", :controller => 'application', :action => 'home' %>
But NOTHING happens in the view, my log shows that is should be
rendered:
Rendering template within layouts/application
Rendering emailer/sendmail
[4;35;1mSQL (0.0ms) [0m [0mSELECT count(*) AS count_all FROM
associates
WHERE (last_request_at > ‘2009-06-12 15:28:25’) [0m
Rendered layouts/_whereabouts (0.0ms)
Completed in 2578ms (View: 16, DB: 32) | 200 OK [http://127.0.0.1/
emailer/sendmail]
why does nothing change on my screen – I still see my Send Email
form? What am I missing here (it must be so obvious, but I simply
don;t see it!) -Janna B