Rails Validations, only integers for :price_in_cents
validates_开发者_如何学运维format_of :price_in_cents, :with =>
What is the regexp for this simple validation
You can use validates_numericality_of with only_integer, combined with positive numbers to represent price in pennies.
/[0-9]+/
Matches one or more integers, however there are better ways to do this (as seen in marklai's answer).
精彩评论