我在PostgreSQL上使用PostGIS ActiveRecord Adapter进行GIS操作和类型。在表格func panGestureEnded(_ chartView: ChartViewBase) {
subscripts.fadeIn()
floatingLabel.fadeOut()
// clear selection by setting highlightValue to nil
chartView.highlightValue(nil)
}
中,我有elements
类型:coordinates
。在ruby中我可以做coordinates.x并返回x坐标。但是我如何在序列化器中解析它?
geometry
在开发回报中:
class ElementSerializer < ActiveModel::Serializer
attributes :coordinates
end
在生产回报中:
"POINT (45.815927 16.00538)"
我想要类似的东西:
0101000000581CCEFC6AE8464003E962D34A013040
想要回归:
class ElementSerializer < ActiveModel::Serializer
attributes {:coordinates => [:coordinates.x, :coordinates.y]}
end
答案 0 :(得分:2)
我不知道为什么在开发环境中序列化程序会返回与生产中不同的东西,但是当涉及到您的主要问题时,您可以在ActiveModelSerializer中执行类似coordinates.x
的代码 - 您只需要通过{ {1}}实例变量,所以下面的代码应该适用于你的情况:
object