0.0
No commit activity in last 3 years
No release in over 3 years
Easily add a contact page with working form to your Rails app.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

Contact

A simple contact form engine. Just add the following to your gemfile:

gem 'flyover-contact'

Mount the engine in your routes file:

mount Contact::Engine, at: "/"

And add an initializer in config/initializers to set some details for the mailer:

Contact.configure do |config|
  config.from_email = "from@example.com"
  config.to_email = "to@example.com"
  config.subject = "New Contact Form Submission"
  config.success_message = "Success! Your message has been sent and we'll get back to you as soon as possible."
  config.base_controller = "::ApplicationController"
  config.contact_page_path = "contact"
end

As long as you have emails set up properly in your app, you will be able to visit /contact and see a simple contact form with validations that will send the info to the address you set in your initializer.

Multiple Forms

To add multiple forms to your site with different "to" email addresses and subjects, you can run rake db:migrate to install the contact_forms table. Just add records to the table with those settings. Then in your views, render the form_container partial with the form's GUID passed in as follows:

Contact::Form.create(to_email: "to@email.com", subject: "New Email!")

Then go into the database to get the Form's guid. It will be a random string like 13ag2302jg9jsf. Use that to render the form_container:

<%= render 'contact/messages/form_container', form: '13ag2302jg9jsf' %>

This project rocks and uses MIT-LICENSE.