Question

I have following migration:

class CreateTariffs < ActiveRecord::Migration
  def change
    create_table :tariffs do |t|
      t.string :name
      t.decimal :amount, precision: 10, scale: 6, default: 0.0
      t.timestamps
    end
  end
end

My migration fails with this exception:

undefined method `sql_type' for #<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::ColumnDefinition:0x000000089a4108>/home/polygalin/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-postgres-array-0.0.9/lib/activerecord-postgres-array/activerecord.rb:42:in `quote_with_array'

But if i remove default value for "amount" column, migration succeeds. Anyone can help to find out why migration fails with default value for decimal column?

Was it helpful?

Solution

I found the reason. It was in activerecord-postgres-array gem. Active Record 4 already have a postgres array support and i just remove it and migration succeeds.

OTHER TIPS

Please try to run the migration with following changes and let me know if it fails.

class CreateTariffs < ActiveRecord::Migration
  def change
    create_table :tariffs do |t|
      t.string :name
      t.decimal :amount, precision: 10, scale: 6, default: 0.00 # or default: 0
      t.timestamps
    end
  end
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top