Convert input to integer before save in rails
- by Micke
Hello, i have a set of select inputs representing a users birthday: birthyear, birthmonth and birthday. And i want to validate birthyear like this:
validates_inclusion_of :birthyear, :in => Date.today.year-50..Date.today.year-12
So the user can be at least 12 years but at most 50 years when they are registering.
But my problem is that the variable from the input is a string and not an integer.
So how can i convert the input to an integer? or is there any easier way to check the users age?
Thanks, Micke