If you ever need to validate currency in your Ruby on Rails app, simply add the following line of code to the model of your choice.


validates :price, :presence => true,
            :numericality => true,
            :format => { :with => /^\d{1,4}(\.\d{0,2})?$/ }
This will allow values of up to $9999.99 with an optional decimal place (if the decimal is present, no more than 2 digits must follow.) Tweak as needed.