rails/rails — pull request #11444 by inopinatus (2013-07-15 02:50:28+00:00)
Title: Resolve encoding issues with array-of-hstore columns (fixes bug 11135).

We didn't have enough encoding for the wire protocol to store an array
of hstore types. So, further encode any hstore that is an array member.
Whilst we're here, ensure it's an HashWithIndifferentAccess being
returned, to be consistent with other serialized forms.

So now the following migration:

enable_extension "hstore"
create_table :servers do |t|
t.string :name
t.hstore :interfaces, array: true
end

produces a model that can used like this, to store an array of hashes:

server = Server.create(name: "server01", interfaces: [
{ name: "bge0", ipv4: "192.0.2.2", state: "up" },
{ name: "de0", state: "disabled", by: "misha" },
{ name: "fe0", state: "up" },
])

More at http://inopinatus.org/2013/07/12/using-arrays-of-hstore-with-rails-4/