Forum: Ruby on Rails Question on creating small mailing list within large applica

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
7f1af56a4fd679069412fc46c7a4378e?d=identicon&s=25 Steve (Guest)
on 2007-04-06 21:23
(Received via mailing list)
I am relatively new to Ruby on Rails and so I am finding myself stuck
on an issue for a web site I am currently designing.

I would like to create a simple mailing list form that just sends the
information from the form fields straight to an email account. I want
this form to be inside of a larger application which is much like a
blog. What is the best way of going about this?
2017657725dd1bce83dc8a1e2e991d04?d=identicon&s=25 Luke Ivers (technodolt1)
on 2007-04-06 22:12
(Received via mailing list)
Rails has a built in mailing mechanism known as ActionMailer... there
TONS of good resources on setting this up correctly, and I'll leave that
part to our friend Google.

Basically, you can do this two ways: set up this form, and have it post
an action that takes the information, sends it over to your already set
action mailer, and then redirects you to a page telling you your mail
succesfully sent.  However, if you don't want to interrupt the flow of
program to much, this is an almost perfect use case for getting into
AJAX.  Simply have the submit button on your form use AJAX instead of a
regular submit, and it will do all the mailing in the background, and
come back and tell your page that it is done mailing.

If you're talking about having the same form perform more than one
(such as, when they click on post to post a blog entry, it also sends an
email), it is simple to have your action you are sending the blog post
information to also create an email out of what you have sent... in the
application I'm currently working on, we use the wonderful Rails method
render_to_string to accomplish this, as that allows us to even use a
layout, etc just like normal, and pass the resulting nicely formatted
stuff off to an action mailer.
7f1af56a4fd679069412fc46c7a4378e?d=identicon&s=25 Steve (Guest)
on 2007-04-06 23:32
(Received via mailing list)
Thanks Luke
This topic is locked and can not be replied to.