If the value is stored as a date in the database, Rails will force the value from the string to the Ruby date when assigned. I think it probably uses the built-in Date.parse ( docs ) method:
Date.parse "2012-10-20" # => #<Date 2012-10-20 ...> Date.parse "20-10-2012" # => #<Date 2012-10-20 ...> Date.parse "10-20-2012" # => ArgumentError: invalid date
In this case, you want to avoid coercion and access the raw string for analysis using Chronic. This is an ideal use case for virtual attributes . There are several ways to do this, something like this should start.
class User < ActiveRecord::Base validate :birthday_is_date
And then use birthday_string in your forms, not birthday .
source share