validates_format_of :first_name, :with => /\A\w+\Z/
The validation doesn't pass if there are non-english character in first name, like Mölläinen
. Changing Rails locale doesn't help. So how do you do culture/locale sensitive validation then?
If the locale is EN
, then \w
should map to [a-zA-Z0-9_]
, but if it's FI
, then it should map to [a-zA-Z0-9_äöåÄÖÅ]
and so on.