Contact and Feedback

A public contact form allows users (authenticated or not) to submit questions, suggestions, bug reports, and flags.

Model (app/models/contact.rb)

  • email, name, description – required fields
  • contact_type – enum: question, suggestion, bug, flag, other
  • admin_note – internal notes for admin follow-up
  • actioned – boolean tracking whether the contact has been handled
  • spam – boolean set by honeypot detection
  • user_id – optional association to a logged-in user
  • ip, city, region, country – geolocation from IP address

Spam Protection

Honeypot fields (website, telephone, address) are present in the form but hidden from real users. If any are filled in, the submission is marked as spam.

Controller (app/controllers/info/contacts_controller.rb)

  • Public controller (no authentication required)
  • Actions: new, create, index (thank you page)
  • On successful submission:
    • Sends notification via Admin::ContactMailer
    • Enqueues Info::GeocodeContactJob to populate city/region/country from IP

Geolocation

The Info::GeocodeContactJob uses the Geocoder gem to resolve the submitter’s IP address to a city, region, and country. This runs asynchronously after submission.

Routes

resources :contacts, only: %i[new create index]
get "contact_us", to: "contacts#new"

Admin

Contacts are viewable in ActiveAdmin with filters on type, spam status, actioned status, and date.


This site uses Just the Docs, a documentation theme for Jekyll.