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 fieldscontact_type– enum:question,suggestion,bug,flag,otheradmin_note– internal notes for admin follow-upactioned– boolean tracking whether the contact has been handledspam– boolean set by honeypot detectionuser_id– optional association to a logged-in userip,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::GeocodeContactJobto populate city/region/country from IP
- Sends notification via
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.