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"] = 'sender@yourdomain.com' @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:
<h1>Send Email</h1> <% form_remote_tag :update => 'contaner', :url => {:controller => 'emailer', :action => 'sendmail'}, :html => {:name => 'form'+(params [:id]).to_s} do %> <p><label for="email_subject">Subject</label>: <%= text_field 'email', 'subject' %></p> <p><label for="email_recipient">Recipient</label>: <%= text_field 'email', 'recipient', :readonly => 'true' %></p> <p><label for="email_message">Message</label><br/> <%= text_area 'email', 'message' %></p> <%= submit_tag "Send" %> <% end %>
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
<center>Message Sent! <br/><br/><br/> <%= link_to "Continue", :controller => 'application', :action => 'home' %> </center>
But NOTHING happens in the view, my log shows that is should be rendered:
Rendering template within layouts/application Rendering emailer/sendmail e[4;35;1mSQL (0.0ms)e[0m e[0mSELECT count(*) AS count_all FROM `associates` WHERE (last_request_at > '2009-06-12 15:28:25') e[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