I have this validation:
validates :year, :presence => true, :numericality => { :only_integer => true }, :uniqueness => true
This works fine in Firefox, but in Chrome the numericality validation isn’t working. If I write 23ab is saved as 23 and doesn’t show errors. Can be because of the tag input type number of HTML5?
Inspect the parameters actually being received by your action (i.e. check your
development.log) and post information as to what’s actually being sent to your controller in theparamshash.The validation in the model happens on the server side after the browser has transmitted the form data, before it’s saved/updated in the database. So, if the exact same input from two different browsers produces different validation results, then it’s probably being modified by the browser before it’s being received by the controller action.
To say it another way: it’s not the validation that is being skipped, it’s the input data that’s being modified, at least most likely. Inspect what’s actually making it to your
paramshash and you’ll be half way home.