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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:46:13+00:00 2026-06-08T23:46:13+00:00

I have three select fields in my view: <%= select(policyholderdetail, dob_day, days_options, {:prompt =>

  • 0

I have three select fields in my view:

<%= select("policyholderdetail", "dob_day", days_options, {:prompt => "#{t :day}"}) %>
<%= select("policyholderdetail", "dob_month", months_options, {:prompt => "#{t :month}"}) %>
<%= select("policyholderdetail", "dob_year", dob_years_options, {:prompt => "#{t :year}"}) %>

Where the values for :dob_day range from 01-31, :dob_month from 01-12 and dob_year from 1912-2012 (last 100 years)

I would like to validate that someone’s date of birth from this is at least 17 years ago, i.e. the person is at least 17 years old. How can I do this in my rails model?

  • 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-08T23:46:14+00:00Added an answer on June 8, 2026 at 11:46 pm

    First you want to make sure that you’re saving only one DateTime to represent all three fields.

    DateOfBirth = Time.parse ("#{ dob_year + dob_month + dob_day } " )
    

    Then you just work against that date :

    validates :is_seventeen?
    
    def is_seventeen?
       DateOfBirth = Time.parse ("#{ dob_year + dob_month + dob_day } " )
       DateOfBirth > Time.now - 17.years ? true : false
    end
    

    Tip..

    Outside of the specific answer, I would recommend that your DateOfBirth field is just one field and that those three selects represent one column in your table.

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

Sidebar

Related Questions

I have three select boxes state,city and locality with the id's same as name
I have three select boxes :- select1 select2 select3 , i am fetching data
I have three table I need to query table 1,2 and 3 and select
I have a table with three columns, and two cells contain select boxes with
I have a select element. <select class='cSelectType'> <option value=1>one</option> <option value=2>two</option> <option value=3>three</option> <option
I have the following HTML markup:- <select name=List1 id=l1> <option>One</option> <option>Two</option> <option>Three</option> <option>Four</option> <option>Five</option>
I have two views with navigation controller: first view, there are empty text fields
I have a form with a select box and three text input boxes. When
I have a view with some fields (name, price, category) and a segmented control,
I have three tables like this: Table 1 structure: Name: registered_applicant_details Fields: applicant_id INT

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.