Project

pg-xml

0.0
No commit activity in last 3 years
No release in over 3 years
postgresql xml datatype support for activerecord -- heavily based on pg-hstore and activerecord-postgres-hstore
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
 Project Readme

pg-xml

Heavily based on pg-hstore and activerecord-postgres-hstore gems.

Use:

gem 'pg-xml'

to include it.

This does two things:

##Nice XML-object attribute

Define an XML column type in your model

class User < ActiveRecord::Base
  has_xml_column :properties
end

This will

  • validate the XML before saving
  • serialize and deserialize it as an XML object
  • allow you to use properties = '' to set an XML object

##Nice xpath indexing

To me this is the whole point of XML as a datatype in postgres is that you can index into it.

class AddIndexToPersonFirstName < ActiveRecord::Migration
  def change
    add_xpath_index :users, :properties, '/xml/first_name'
  end 
end

##Known issues

I've used it with nokogiri. I sort of tried to make it work with Hpricot also but I didn't follow through on that.

It also doesn't have specs to test.

And the migrations aren't properly reversible.