The contact form component adds a Contact page (view), which displays a contact form, along with a controller to process form submissions and a mailer to send form submissions to an email address.
It also includes a spam protection widget powered by Cloudflare Turnstile. The Cloudflare Turnstile implementation uses the railscloudflareturnstile gem.
You can install the contact form component by running the following command:
rails g instrumental:contact_form
Follow the instructions in the Cloudflare Turnstile documentation to configure Cloudflare Turnstile.
Be sure to restart your server after saving your Rails credentials and initalizer.
Now your Contact form should be viewable at /contact
.
Note: Your contact_controller.rb
has allow_unauthenticated_access
which makes your Contact view and form submissions available to the public. If you want it to be available only to logged-in users, then remove allow_unauthenticated_access
(assuming you’re using Rails authentication, which is what Instrumental Authentication Component is built on).
The Contact Form component installs contact_mailer.rb
along with an HTML and text email. This sends the contact form submissions to an email address of your choosing.
The email address that submissions are sent to is defined in contact_mailer.rb
Submission emails are set up to include the following:
I created Instrumental Components to make designing and building professional apps with Ruby on Rails easy, fast, and fun. I use it on all of my projects and I hope it helps you build something great.