I'm referring to Rails 3.2's Data Store feature, in which there's the option to store key-value stores in a textfield, even if you're using a relational database like MySQL...it works fine when programmatically manipulating the fields.
But what documentation is there to update these fields from a RESTful HTML form? Or is this something that's not recommended at all? That is, the better solution would be to go to NoSQL?
If I understand the question, I think you just need to declare the field name holding the store, and the associated accessors (properties) in the model, like
at which point the field works with AR and AREL just like any other, even with forms.
There's very little magic here. The field holds a hash of values; the store declaration lets Rails know that you can reference them like something.weight or something.color, whether reading or writing. Simple and slick. Classic DHH.
although the question is quite old someone else might find it useful, also im pretty new in ruby and rails so there might be a better way to do this.
In the model:
then in the form partial:
Now to add some extra fields from the form ive created 2 attr_accessor in the model:
then added the 2 new fields on the form
on my controller i made a function that check the presence of the new fields and then merge the previous values of the prefs with new ones, like this:
done that i return it and pass it to the update_attributes, hope it helped!