开发者

What's your solution for 'contact forms' in Ruby on Rails applications?

With a quick Google search, one can find literally hundreds of examples for contact forms using PHP and/or JavaScript, but there don't seem to be any "ready-made" contact forms for Ruby on Rails. Do 开发者_运维问答they exist? What do you use for contact forms in your Ruby on Rails apps?


Personally, I use an ActiveRecord model for mine as I like to keep a store of messages being sent, and then use an ActionMailer after saving a record to send an email.

Alternatively there is a gem called MailForm which allows you to build a form model without a database table, which will work with other gems such as Formtastic.

As for ready-made contact forms, I don't know of any (though they may well exist) as it's not particularly time-consuming to build one from scratch.


I was running into the same issue with wanting an easy to use out of the box Contact Form, but wasn't able to find one. So I've written ContactUs a Rails Engine that you can easily drop into any Rails 3+ application. I tried to keep it dead simple and as easily configurable as possible. It does require the Formtastic gem since I wanted an easy way to hook into peoples existing form styles though.

To install the Engine add the contact_us gem to your Gemfile:

gem 'contact_us', '~> 0.1.3'

Run bundle and the install rake task:

$ bundle
$ bundle exec rake contact_us:install

Then just modify the generated initializer in /config/initializers/contact_us.rb to have the email you want the form submissions sent to.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜