Changing a column data type with Rails migration not working (using PG DB)
===

I'm having problems changing the data type of a particular model's attribute (i.e. money). Money was an integer -- I'm trying to use a migration to change it to a decimal, with a precision of 5 and a scale of 2. Upon doing the migration, everything looks OK in console (i.e. it appears the migration worked), but when I go to change a value to a decimal in the web app, I get an 'Invalid value' message. Here are the steps I take:

First, I generate the migration:

    >rails generate migration change_data_type_for_user_money

Then, I edit the migration. Here's what it looks like:

    class ChangeDataTypeForUserMoney < ActiveRecord::Migration
      def self.up
        change_table :users do |t|
          t.change :money, :decimal, :precision => 5, :scale => 2
        end
      end
    
      def self.down
        change_table :users do |t|
          t.change :money, :decimal, :precision => 5, :scale => 2
        end
      end
    end

Then I do a 'rake db:migrate'

What is odd is that zero's following the decimal point appear and are fine (e.g. 100.00 is OK, but 100.50 is when I get the error)

Any thoughts? Thanks in advance for your help!


