This may fall under the "why would you want to" category, but the validates_confirmation_of validation does not properly validate decimal (BigDecimal) columns. Example:
create_table :payments do |t|
t.decimal :amount, :precision => 10, :scale => 2
end
class Payment < ActiveRecord::Base
validates_confirmation_of :amount
end
-
Lets make believe this is string form data
script/console
>> p = Payment.new(:amount => "0.25", :amount_confirmation => "0.25")
>> p.save
=> false
>> p.errors.full_messages
=> ["Amount doesn't match confirmation"]
--------------------------------------
This appears to be due to the fact that the amount_confirmation value is not being cast to a BigDecimal like the amount value is. Adding this hack to the Payment model fixes the issue
def amount_confirmation
column_for_attribute(:amount).type_cast(@amount_confirmation)
end