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 8545011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:41:32+00:00 2026-06-11T12:41:32+00:00

Relatively new rails programmer here, so bear with me. I have an app where

  • 0

Relatively new rails programmer here, so bear with me.

I have an app where registered users can create polls but anyone can answer the polls.

I am using Devise for my authentication. I want non-authenticated users to be able to answer the polls but I want to prevent double-voting.

I assume this should be done with persistent (not session) cookies, but I’m not sure. So when the user enters the site, I create a user in devise and I store some random value in both the User model and in the cookie, and I check that the user has not answered the question previously when he/she attempts to load my “answer” page?

Can someone give me some advice on whether this is the right approach and/or point me towards a resource to help me get started?

I have found relatively little information out there on how to manage persistent cookies in Rails.

  • 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-06-11T12:41:33+00:00Added an answer on June 11, 2026 at 12:41 pm

    You can’t reliably prevent people from voting multiple times without logging in. It’s not possible. I guess people could also create multiple user accounts to vote so there is no fool proof way.
    Cookies are often cleared automatically by certain popular cleaners and unless you are only going to allow people to vote on a product they have purchased I think you are kind fighting a lost battle.

    Stack Overflow limits voting capability by making sure a certain level has been achieved before being allowed to vote but I guess that’s not really applicable to your scenario.

    This is not so much about sessions and cookies and more about setting up your database to record a vote including the voter id.

    In the view that allows users to vote I would suggest that you switch between a voted icon and a vote now link depending on whether or not the currently logged in user has voted.

    To determine if the user has voted then include the user id of the currently logged in user in a question_vote xref table.

    For the belt and braces approach to prevent abuse of the html in the browser add the check to the validations of the question_vote record.

    I would do this by adding a can_vote? method to the user model that accepts a question id as a parameter then you can use the question_id plus the user id to find a matching record in the question_vote table if a reordx is found return false otherwise return true

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

Sidebar

Related Questions

Relatively new to rails, I'm working on a simple rails app for a few
Relatively new to WinForms but I'm working on a small business app. Anyway, where
Im relatively new to the Android world but I have a quick question. I
relatively new programmer here. Look at the two classes defined below. I'd like to
Im relatively new to PHP but have realized it is a powerfull tool. So
I'm relatively new to Rails and busy building an app with various access levels,
Relatively new to Cocoa here. This question is about NSFileHandle, but I got a
I am relatively new to rails and have been working my way through the
I am relatively new to Rails. I have a User model through Devise. I
I am relatively new to the rails syntax. I have a LogString class class

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.