Blog

Contact Form gem for Rails3

Contact Form gem for Rails3

Today I wrote a little gem which contains a contact form. It is build with the enginex engine skeleton and is a full mountable rails engine. You can easily integrate the code into your rails project and you can customize it the way you like.

The gem contains a form which gets send by mail to an user. The user gets an auto reply mail and the website administrator gets a mail with the contact data. Just simple, but comfortable.

Quick Start

gem install contact_form

Or add it to your Gemfile:

gem "contact_form"

Run the generator to generate an initializer file, a config yml file and locale files

rails g contact_form:install

You can easily customize all files. The generated file under “/config” contains the mailer recipients, you can change them the way you want. The generated files under “/config/locales” contains i18n keys which can also be changed.

After you run the generator you can mount the engine in your routes.rb

mount ContactForm::Engine => "/contact_form"

Visit

localhost:3000/contact_form

and you’ll see the result!

Generators

There are following generators available for customizing your contact form:

rails g contact_form:views        # generates view files
rails g contact_form:models       # generates model files
rails g contact_form:controllers  # generates controller files
rails g contact_form:mailers      # generates mailer files

 

Or simple generate all files

rails g contact_form:all          # generates all files

The gem is published under the MIT license.

You can find further information on github: https://github.com/mattherick/contact_form

Feel free to open issuses or make a pull request, if something does not work the way you want.

20.08.2012
Matthias Frick
Ruby on Rails
6 Kommentare

Über den Autor

Matthias Frick
Matthias Frick, MSc.

Er ist ein langjähriger Ruby-on-Rails Entwickler und leitet das Unternehmen Frick-Web.

6 Kommentare zu "Contact Form gem for Rails3"

  1. Chilaro Hilma
    Chilaro Hilma 04.10.2012
    Very convenient generators guy! Thanks a lot!
  2. Raul Pepe
    Raul Pepe 06.11.2012
    Thanks, saved me a lot of time! I like your ActiveModel class.
  3. Andrew Murpheys
    Andrew Murpheys 02.01.2014
    Thanks for sharing!
  4. mbt clearance shoes
    mbt clearance shoes 22.06.2015
    mbt shoes online
  5. mbt trainers
    mbt trainers 20.06.2017
    http://www.castleton.co.uk
  6. mbt trainers sale
    mbt trainers sale 20.06.2017
    http://www.castleton.co.uk/activities/

Kommentar verfassen