madeintandem / hstore_accessor

Adds typed hstore-backed field support to ActiveRecord models.
MIT License
242 stars 47 forks source link

Fix collection default values #30

Closed tobmatth closed 9 years ago

tobmatth commented 9 years ago

Fixes #20

tobmatth commented 9 years ago

Please note that this is just cosmetics. You will still need to go through the setter, e.g.

class MyClass < AR:B
  hstore_accessor :properties, my_attribute: :hash
end

c = MyClass.new
c.my_attribute 
=> {}
c.my_attribute[:one] = 1 # won't work
=> 1
c.my_attribute
=> {}
c.my_attribute = {one: 1} # will work
=> {:one=>1}
c.my_attribute
=> {:one=>1}
tobmatth commented 9 years ago

Ok, so i'm closing here as as fixed in pull request #31 in a much more elegant way...