【发布时间】: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