This project is archived and is in readonly mode.

#115 ✓stale
Brad Sumersford

validates_confirmation_of does not confirm with decimal column type

Reported by Brad Sumersford | May 5th, 2008 @ 05:12 PM

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


class Payment < ActiveRecord::Base

validates_confirmation_of :amount


  1. Lets make believe this is string form data


>> p = => "0.25", :amount_confirmation => "0.25")


=> 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



Comments and changes to this ticket

  • josh

    josh July 17th, 2008 @ 01:09 AM

    • State changed from “new” to “stale”
    • Tag cleared.

    Closing this ticket as stale. If this is still an issue for you, feel free to reopen this ticket or create a new one with an updated description. Remember those unit tests too ;)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

People watching this ticket