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:
-----------------
ActionView::MissingTemplate (Missing template emailer/list.erb in view
path app/views):
app/controllers/emailer_controller.rb:11:in `sendmail''
Rendering rescues/layout (internal_server_error)
--------------------
But I do have an application controller and it does have a home
method. Why does ActionMailer not forward onto there in my render
command? How, typically, can I put the view back to what it WAS before
the user elected to send an email ? -Janna B
On Jun 10, 5:46 pm, JannaB <mistressja...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> 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> 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: > > ----------------- > ActionView::MissingTemplate (Missing template emailer/list.erb in view > path app/views): > app/controllers/emailer_controller.rb:11:in `sendmail'' > > Rendering rescues/layout (internal_server_error) > -------------------- > > But I do have an application controller and it does have a home > method. Why does ActionMailer not forward onto there in my render > command? How, typically, can I put the view back to what it WAS before > the user elected to send an email ? -Janna B
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
On Jun 10, 1:24 pm, Frederick Cheung
<frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> On Jun 10, 5:46 pm, JannaB
<mistressja...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> 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
>
> > 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:
>
> > -----------------
> > ActionView::MissingTemplate (Missing template emailer/list.erb in view
> > path app/views):
> > app/controllers/emailer_controller.rb:11:in `sendmail''
>
> > Rendering rescues/layout (internal_server_error)
> > --------------------
>
> > But I do have an application controller and it does have a home
> > method. Why does ActionMailer not forward onto there in my render
> > command? How, typically, can I put the view back to what it WAS before
> > the user elected to send an email ? -Janna B
Oh wait....it;s so easy...just close the div in javascript. Bingo! On Jun 10, 2:39 pm, JannaB <mistressja...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> 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 > > On Jun 10, 1:24 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > On Jun 10, 5:46 pm, JannaB <mistressja...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> 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 > > > > 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: > > > > ----------------- > > > ActionView::MissingTemplate (Missing template emailer/list.erb in view > > > path app/views): > > > app/controllers/emailer_controller.rb:11:in `sendmail'' > > > > Rendering rescues/layout (internal_server_error) > > > -------------------- > > > > But I do have an application controller and it does have a home > > > method. Why does ActionMailer not forward onto there in my render > > > command? How, typically, can I put the view back to what it WAS before > > > the user elected to send an email ? -Janna B
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. 2009/6/12, JannaB <mistressjanna-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org>:> > 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 > > >-- Von meinen Mobilgerät aus gesendet