ActiveRecord 使用 JSON 而不是 YAML 进行序列化 [英] ActiveRecord serialize using JSON instead of YAML
本文介绍了ActiveRecord 使用 JSON 而不是 YAML 进行序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个使用序列化列的模型:
I have a model that uses a serialized column:
class Form < ActiveRecord::Base
serialize :options, Hash
end
有没有办法让这个序列化使用 JSON 而不是 YAML?
Is there a way to make this serialization use JSON instead of YAML?
推荐答案
在 Rails 3.1 中你可以
In Rails 3.1 you can just
class Form < ActiveRecord::Base
serialize :column, JSON
end
希望有帮助
这篇关于ActiveRecord 使用 JSON 而不是 YAML 进行序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文