Reputation: 29
I am a rather green RubyOnRails developer. My apologies in advance for the rather simplistic nature of this question.
I am trying to create a page in my RoR app that allows a user to enter the email addresses of friends/family. When the user hits the 'invite' button at the bottom of the form, the app will send invitation emails to the addresses that are entered.
Since the form doesn't corresponding to a model, I can probably use a simple form helper (i.e. form_tag). Also, I've watched the (very good) railscast on how to set up ActionMailer (# 61) and feel comfortable doing this.
My confusion is how to 'link' the form submission (with the email addresses) to the ActionMailer class(es). According to the form description page, I need to specify a named route in the submit tag.
How can I specify a named route for the ActionMailer class(es) and how do I get the user to an acceptable page (i.e. "thank you for the invitations") after they press the 'invite' button.
Thanks in advance!
Upvotes: 0
Views: 276
Reputation: 2341
This railscasts is probably the best for learning to send email.
http://railscasts.com/episodes/61-sending-email
Upvotes: 1
Reputation: 5301
The form submission has nothing to do with ActionMailer, directly speaking. Just put your ActionMailer call in an action somewhere, and then point your form at that route.
In routes.rb
match '/send_invite' => 'the_controller#send_invite', :as => :send_invite
Point your form to '/send_invite' (or the send_invite_path helper, which will return that string).
Then in "the_controller", define the method "send_invite", and put your ActionMailer code there. Then render a view with your "thank you for the invites" message.
Upvotes: 1