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

  • SEARCH
  • Home
  • 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 840053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:33:49+00:00 2026-05-15T05:33:49+00:00

I was wondering how to go about form validation in rails. Specifically, here is

  • 0

I was wondering how to go about form validation in rails. Specifically, here is what I’m trying to do:

The form lets the user select an item from a drop down menu, and then enter a number along with it. Using RJS, the record instantly shows up in a table below the form. Resetting the form with AJAX isn’t a problem.

The issue is, I don’t want the person to be able to select the same item from that drop down menu twice (in 1 day at least). Without using ajax, this isn’t a problem (as I have a function for the select statement currently), but now that the page isn’t reloading, I need a way to make sure people cant add the same item twice in one day.

That said, is there a way to use some javascript/ajax validation to make sure the same record hasn’t been submitted during that day, before a duplicate can be created?

Thanks in advance!

Elliot

  • 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-15T05:33:49+00:00Added an answer on May 15, 2026 at 5:33 am

    With regards to form validations, for your special logic, you’ll want to override #validate in your model. See the docs for ActiveRecord::Validations#validate.

    Your best bet to “make sure people cant add the same item twice in one day” is to not present the user with options that they can’t select. When your controller prepares data for the view have logic that filters out any options that the user shouldn’t have (i.e. those they already selected that day). Or present them but disable them as options (so they are grayed out). If the user could select the same option twice in one request you’ll want some JS to do client-side validation before a POST to the server.

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

Sidebar

Related Questions

I'm just wondering what are you thinking about DIV-tag inside FORM-tag? I need something
I'm about to encrypt my website's login form and I was wondering if the
an input text element posts an empty string I am wondering about a form
I was wondering about an initialization of the following form: int array[] = {
Is the following valid HTML? What I am wondering about specifically is the location
I'm writing some form views in my Rails 3 app, and I am wondering
I am fairly new to access and I am wondering about a form. In
I'm wondering about graphics on form buttons. I'm using form buttons instead of links
I'm wondering how you might go about implementing multiple form actions when submitting a
I was wondering about the best way to implement a Confirm Page upon form

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.