Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3690614
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:03:18+00:00 2026-05-19T04:03:18+00:00

I have an app that supports email subscriptions, surveys, and comment forms. I’ve got

  • 0

I have an app that supports email subscriptions, surveys, and comment forms. I’ve got a model for each (Subscription, SurveyResponse and Comment, respectively). I also have a Visitor model to store shared information like name, email, phone, etc.

I’m wondering how to best tie the models together. Using a one-to-one association between each model and the Visitor model would treat each event separately. So, if John Doe submitted a comment and a survey, he would get two records in the visitors table. I’m leaning towards this approach – it’s simpler.

On the other hand, I could set up a one-to-many association on Visitor with a unique constraint on email. I could then attempt to tie each event to an already existing record, something like:

@visitor = Visitor.find_by_email(params[:email]) || Visitor.new(params)

This approach seems problematic since I can never be certain that I’m getting the right record. What if two different people submit a comment using “spam@example.com”? Unlikely, but possible

Is there a better way to approach this problem?

A few clarifications:

  • I’m not planning to ever have full-fledged user accounts for regular site visitors.

  • Validations are very minimal (new subscriptions verify that an email is passed, comments require text in the comment field, but most fields are optional)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T04:03:19+00:00Added an answer on May 19, 2026 at 4:03 am

    If you’re never planning on having a full users system or verifying email addresses then you’re probably better off with the one-to-one association. It’s essentially the same as hard-coding the fields of the visitor model into each of the other tables, but cutting down on repetition. If you don’t care that the same email address can have different names, phone numbers, etc across your site then stick with that.

    If you want the names, phone numbers, etc to always be the most recent used then do an update on the visitors table when they submit something.

    You can use a cookie to pre-fill in the form fields, for convenience but this doesn’t prevent someone from entering in conflicting information on another computer or browser.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have installed rubycas-server on my server. I have a ruby app that supports
I'm writing a web app that supports multiple users. Each user has their own
I have been support a web app that is used by a user base
I have an app that needs to open a new window (in the same
I have an app that executes commands on a Linux server via SSH just
I have a app that I'm deploying to a development server using Capistrano. I'd
I have an app that is failing on the install. The vendor says I
I have an App that will send authenticated emails using System.Net.Mail and System.Net.NetworkCredential my
I have an app that needs to handle very large strings between a SQL
I have an app that I'm writing a little wizard for. It automated a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.