Julian ''Julik'' Tarkhanov
2006-Jun-18 20:39 UTC
[Rails] Put an arbitary hash into ActiveRecord
Did someone encountered a problem of putting a hash of values into AR, into a certain field? Essentially I need some denormalized, freeform serializable hash to which the user can add keys and values, and handle accessors from there would be lovely too. I remember that AR has "serialize" but did someone actually use it? I heard nothing but complaints about rich objects in AR columns. TIA. -- Julian ''Julik'' Tarkhanov me at julik.nl
On Jun 18, 2006, at 1:39 PM, Julian ''Julik'' Tarkhanov wrote:> Did someone encountered a problem of putting a hash of values into > AR, into a certain field? > > Essentially I need some denormalized, freeform serializable hash to > which the user can add keys and values, and handle accessors from > there would be lovely too. I remember that AR has "serialize" but > did someone actually use it? I heard nothing but complaints about > rich objects in AR columns. > > TIA. > -- > Julian ''Julik'' Tarkhanov > me at julik.nl >Julian- I have used a serialized hash in a some models before and it worked great for free form stuff. Of course you lose the ability to search these fields with sql but I think thats an ok trade off for free form values. Although you can use ferret to index the serialized hashes to allow for search within the hashes as well. All in all it is a very workable solution to a freeform data column. And I see no problems with it as long as you are aware of the limitations. Cheers- -Ezra