【问题标题】:Hstore array attribute won't update in code, but works in consoleHstore 数组属性不会在代码中更新,但可以在控制台中使用
【发布时间】:2015-04-01 03:41:30
【问题描述】:

这适用于 Rails 控制台:

pry(main)> calendar.update({"open_times"=>[{"start"=>"1111-11-11T00:30:00.000Z", "end"=>"1111-11-11T04:00:00.000Z", "title"=>" "}]})
   (0.3ms)  SAVEPOINT active_record_1
   (0.2ms)  RELEASE SAVEPOINT active_record_1
=> true

但相同的更新方法在其他任何地方都不起作用(模型、控制器等)。返回的错误是TypeError: can't cast Array to。它甚至没有说明我不能将数组转换为什么(尽管我假设是 hstore)。

这是我对专栏的迁移:

def change
  enable_extension 'hstore'
  add_column :calendars, :open_times, :hstore, array: true, default: [], null: false
end

想法?

【问题讨论】:

  • 检查 PostgreSQL 错误日志中 Rails 运行的语句和完整错误。

标签: postgresql ruby-on-rails-4 hstore


【解决方案1】:

重新启动我的所有服务器(Rails/Postgres),然后再试一次。工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-09-28
    • 2022-08-21
    • 1970-01-01
    • 1970-01-01
    • 2020-09-29
    • 1970-01-01
    • 2020-03-14
    • 1970-01-01
    相关资源
    最近更新 更多