【问题标题】:Rails decimal migration produces integer columnsRails 十进制迁移产生整数列
【发布时间】:2012-11-01 16:18:43
【问题描述】:

我正在使用 mysql2 gem (v0.3.11) 运行 Rails 3.1.1。出于某种原因,当向表中添加一些小数列时,它会生成整数字段。它没有给我任何错误,并且迁移显示正在创建十进制列。有没有其他人遇到过这个问题?这是我迁移中的一行:

add_column :tracks, :energy, :decimal, precision: 18

我通常不会跑到 StackOverflow,但我真的不知道到哪里寻找问题。

【问题讨论】:

  • 你能从schema.rb发布“曲目”块吗?

标签: mysql ruby-on-rails migration decimal


【解决方案1】:

尝试在迁移的行中添加:scale => x(其中x 是您需要的小数点右侧的数字)。

source and more information

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-22
    • 2021-07-11
    • 1970-01-01
    • 2014-07-10
    • 1970-01-01
    • 2022-12-01
    • 1970-01-01
    • 2018-02-13
    相关资源
    最近更新 更多