Ruby on rails Rails-在Heroku的浮点列中插入十进制时出错
我有一个通过这次迁移创建的开发表:Ruby on rails Rails-在Heroku的浮点列中插入十进制时出错,ruby-on-rails,heroku,rounding,Ruby On Rails,Heroku,Rounding,我有一个通过这次迁移创建的开发表: class CreateMateriales < ActiveRecord::Migration def change create_table :materiales do |t| t.belongs_to :refaccion, index: true t.belongs_to :solmate, index: true t.integer :partida t.integer :pedida t.integer
class CreateMateriales < ActiveRecord::Migration
def change
create_table :materiales do |t|
t.belongs_to :refaccion, index: true
t.belongs_to :solmate, index: true
t.integer :partida
t.integer :pedida
t.integer :surtida
t.timestamps null: false
end
end
end
class ChangeTypesPedidaSurtidaMateriales < ActiveRecord::Migration
def self.up
change_column :materiales, :pedida, :float
change_column :materiales, :surtida, :float
end
def self.down
change_column :materiales, :pedida, :integer
change_column :materiales, :surtida, :integer
end
end
它在开发过程中做到了这一点,但当我把它推给Heroku时,它只是将它们存储为整数。我跟踪了数据,注意到它是以小数形式发送的,它很好地到达,但在INSERT_INTO
命令中,它是四舍五入的:
我还在Heroku的控制台上做了一个测试,它实际上正确地保存了它
你知道为什么会变圆吗?我正在异步发送它。我在Heroku的开发中使用sqlite3,在生产中使用Postgresql。推到生产中,运行了迁移,但一开始不起作用,但经过一段时间(大约10分钟)后,更改现在可见了。我不知道这是否是Heroku上的一个bug。您是否为生产运行了迁移?@HieuPham我运行了,他们运行得很好,但显然需要一段时间(比如10分钟)才能真正进行更改,这很奇怪。现在它正在按预期工作,无论如何谢谢你!