ActionMailer Views Confusion

I have an ActionMailer, which has a corresponding controller (shown below). The form to create the email gets invoked from another form, a list of names and email addresses from another Model. I would like to return to this list after the mail is sent (for now, however, I am merely trying to return to Application.home() )

I have:

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);

    render :controller => 'application', :action => 'home'

  end end

Nothing happens -- nothing with the view changes after I click send on the form that feeds sendmail(), though the sendmail() gets executed and the mail properly sent. When I look into my logs, I see:

I have an ActionMailer, which has a corresponding controller (shown below). The form to create the email gets invoked from another form, a list of names and email addresses from another Model. I would like to return to this list after the mail is sent (for now, however, I am merely trying to return to Application.home() )

So do you actually want redirect_to rather than render ?

Fred

Frederick

Either one -- but niether get hit:

def sendmail        recipient = params[:email][:recipient]        subject = params[:email][:subject]        message = params[:email][:message]        returnadd = current_associate.email        puts "about to send"        mymail = Emailer.create_contact(recipient, subject, message, returnadd)        Emailer.deliver(mymail);        puts "sent!"        redirect_to :controller => 'application', :action => 'home'   end

see, the "sent" is appearing....but nothing ever redirects! Any thoughts or suggestions here on this? Thanks! -Janna B

Oh wait....it;s so easy...just close the div in javascript. Bingo!

I'm trying to implement this on a Blackberry (whose support for Javascript is something of a joke, even when it is enabled) there has to be a proper way to redirect this in rails which does not involve javascript. It seems neither redirect_to nor render get called (though, the puts line above it does, and the mail is correctly sent!).

So why can;t a redirect anywhere after this? -Janna B

According to the quoted exception the problem here is not the redirect. It is the actionmailer which doesnt find the template to render the email. This raises an exception and prevents further processing of your controller action. Name your email templates in the form name.text.plain.erb or name.text.html.erb depending on the mime type.