git clone http://github.com/tilo/mail_form_example_with_recaptcha
The mail_form gem allows you to create forms directly in Rails 3 without a database backend. As soon as you submit the form, it gets emailed to an address you specify.
You might have read about the mail_form gem either on the web or in the Pragmatic Programmer's book "Crafting Rails Applications".
Unfortunately this example is incomplete:
The recaptcha gem allows you to make sure that a human (not a bot) is submitting your forms. The recaptcha gem uses Google's ReCAPTCHA service. ReCAPTCHA is a free CAPTCHA service that helps to digitize books, newspapers and old time radio shows.
gem clone git://github.com/tilo/mail_form_example_with_recaptcha.git
emacs Gemfile
bundle install
By default, your reCAPTCHA key is restricted to the specified domain, and any subdomains for additional security. This is why you need to sign-up, to get your API-key for your specific domain.
https://www.google.com/recaptcha/admin/create
emacs config/initializers/recaptcha.rb
emacs config/initializers/setup_mail.rb
emacs app/models/mail_forms/contact.rb
http://code.google.com/apis/recaptcha/docs/customization.html
emacs app/views/mail_forms/contact/new.html.erb
rails s
firefox http://localhost:3000/contact
Enjoy!
. ├── app │ ├── controllers │ │ ├── ... │ │ └── mail_forms │ │ └── contact_controller.rb │ │ ... │ ├── models │ │ └── mail_forms │ │ └── contact.rb │ │ ... │ └── views │ └── mail_forms │ └── contact │ └── new.html.erb │ ... ├── config │ │ ... │ ├── initializers │ │ ├── recaptcha.rb │ │ └── setup_mail.rb │ │ ...