I’m using the GeoRuby and Spatial Adapter to do some postgis stuff with
rails. Working great. The thing is, these define custom types that get
stored on these activerecord objects. Things like
GeoRuby::SimpleFeatures::Point. So when I call to_xml everything is
peachy except for that datatype.
So what I did was define to_json and to_xml methods for these types.
They work fine.
<?xml version="1.0" encoding="UTF-8"?> -123.333297729 49.0BiologicalMetric.find(:first).geometry.to_xml
=>
So I thought that this would solve all my problems and even be something
I could contribute to the georuby library. Very DRY eh? Wrong!!!
ActiveRecord doesn’t seem to call the to_xml method on these datatypes.
It just does it’s own thing. The JSON serialization ignores the custom
methods as well.
Am I missing something? Why wouldn’t to_xml/to_json be called when the
parent object’s to_xml/to_json method is called?
Thanks,
Chad B.