What I am trying to do is have the user enter a 2 digit birth year in
the view, then have the controller do it's magic and get a 4 digit
date for the birthday. That part went fine, but now I'm having trouble
replacing the 2 digit year in params with the correct 4 digit value
before the create/update to the database. Please Help
What I am trying to do is have the user enter a 2 digit birth year in
the view, then have the controller do it's magic and get a 4 digit
date for the birthday.
That should probably be done in the model, not the controller.
That part went fine, but now I'm having trouble
replacing the 2 digit year in params with the correct 4 digit value
before the create/update to the database. Please Help
Just assign appropriately:
params[:birth_year] += 1900
That part went fine, but now I'm having trouble
replacing the 2 digit year in params with the correct 4 digit value
before the create/update to the database. Please Help
Just assign appropriately:
params[:birth_year] += 1900
Careful. My kid was born in 2004... not 1904. He probably won't be signing up on your website, but then again he recently admonished me for not knowing about youtube playlists so you never know.
Better to check the 2 digits... if it's less than 09 add 2000. Otherwise add 1900. Of course that will tick off all your 100-yr old users