Proper Use of Mailer in Rails 3
I want to add a form to contact me via email on my site. I was going to cre开发者_高级运维ate s StaticPages controller and use that to show the view for my contact form. However, I don't know how I would manage sending the emails unless I had a dedicated controller for my contact form.
What is the proper design to implement a way to have an email sent to me through a form in my application?
You should have a single controller for the contact form, and no ActiveRecord model.
You may wish to read the Rails Guide on ActionMailer for how to create an ActionMailer model.
Have a ContactForm controller. Have it display the form, have another method to call your ActionMailer deliver() method.
精彩评论