Date Validation for date_select

I am new to Rails and I am building this website based on the tutorials
from a book called Railspace. My problem is I have a form page which
accepts the date for
a birthdate field

  <div class="form_row">
    <label for="birthdate"> Birthdate </label>
    <%= date_select :spec, :birthdate,
                                      :order =>[:month, :day, :year]



It works fine when I enter correct dates but when I try entering
something like Feb 31 2009 it gives me the following error.

   1 error(s) on assignment of multiparameter attributes

My parameter variable shows that its being passed as 3 seperate values
(that is my understanding please correct me if I am wrong)

{“commit”=>“Update”, “spec”=>{“city”=>“Atlanta”, “occupation”=>“Software
programmer”, “zip_code”=>“21312”, “birthdate(1i)”=>“1907”,
“gender”=>“Male”, “birthdate(2i)”=>“2”, “birthdate(3i)”=>“31”,
“first_name”=>“Dilbert”, “last_name”=>“Dilbert”, “state”=>“Georgia”}}

I cannot seem to validate this using the validate method on the
controller as I am unable to fetch the values of the parameters.
Ive tried using something like

def validate
if (birthdate.month==2 && > 29)
errors.add(:birthdate, “Invalida date”)

but its seems to completely bypass this. It works correctly when i
simply type
if(birthdate.month==2 )
but I dont seem to understand why I cannot validate it.

Could someone explain this to me.
Thanks in advance.

Im sorry the validate method in the model (Spec which stores
specifications of the registered users)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs