ContactForm

This gem contains a little contact form. It is build with a mountable engine. It is simple and just sends two emails. Nothing gets saved to the database. The first email is to the website administrator and the second email is an auto reply to the user.

This gem is compatible with rails 4.1.x, 4.0.0 and rails 3.2. For rails 4.0.0 you must use the version 0.0.4, or the branch “rails_40”. For rails 3.2 you must use the version 0.0.2, or the branch “rails_32”.

Quick Start

rails 4.1.0:

gem install contact_form

Or add it to your Gemfile:

gem "contact_form"

rails 4.0.0:

gem install contact_form -v 0.0.4

Or add it to your Gemfile:

gem "contact_form", "0.0.4"

or directly from the rails 4.0.0 branch from github:

gem "contact_form", :git => "https://github.com/mattherick/contact_form.git", :branch => "rails_40"

rails 3.2:

gem install contact_form -v 0.0.2

Or add it to your Gemfile:

gem "contact_form", "0.0.2"

or directly from the rails 3.2 branch from github:

gem "contact_form", :git => "https://github.com/mattherick/contact_form.git", :branch => "rails_32"

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", :as => :contact_form

Visit

http://localhost:3000/contact_form

and you’ll see the result! You can override this route in your route file.

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

Copyright © 2012 - 2014 Matthias Frick, released under the MIT license