Oh you put me to shame Michael! You're right, I could definitely move this to the model and write a custom validation. Quick question though, won't _before_type_cast return a hash? I'm not sure if I'd be able to call #to_date on it. But I suppose I could just pass the values into a Date object again and rescue the error. Either way, it's a great idea to keep this logic out of the controller! Thank you!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Oh you put me to shame Michael! You're right, I could definitely move this to the model and write a custom validation. Quick question though, won't
_before_type_cast
return a hash? I'm not sure if I'd be able to call#to_date
on it. But I suppose I could just pass the values into aDate
object again and rescue the error. Either way, it's a great idea to keep this logic out of the controller! Thank you!