Anyone work on, or interested in, a acts_as_hash? It would allow things like product.properties[''isbn''] = 32232323 product.properties[''color''] = ''blue'' product.save id = product.id .... p = Product.find(id) p[''color''] #=> ''blue'' ... Product.hashfind_by_properties(''isbn'', 32232323) #=> p It''s useful when the properties you need to store are always changing, so you can''t use field mapping, but you want to query by them, and so can''t use serializable. Comments? Suggestions? Criticisms? -- Posted via http://www.ruby-forum.com/.
I think this already exists as :serialize Or at least, it works for my purposes. -- On 11/28/05, List Recv <listrecv-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Anyone work on, or interested in, a acts_as_hash? > > It would allow things like > > product.properties[''isbn''] = 32232323 > product.properties[''color''] = ''blue'' > product.save > id = product.id > > .... > > p = Product.find(id) > p[''color''] #=> ''blue'' > > ... > > Product.hashfind_by_properties(''isbn'', 32232323) #=> p > > > It''s useful when the properties you need to store are always changing, > so you can''t use field mapping, but you want to query by them, and so > can''t use serializable. > > Comments? Suggestions? Criticisms? > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Garrick Van Buren ---------------------------------------------------- garrick.vanburen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org ph: 612 325 9110 ----------------------------------------------------- First Crack Podcast http://firstcrackpodcast.com/ gFeed - all my writing in one place http://garrickvanburen.com/gfeed/ PodcastMN - The Sound of Minnesota http://podcastmn.com/ Garrick''s Podcast Picks http://gigadial.com/public/station/9454
garrick.vanburen wrote:> I think this already exists as :serialize >You can''t do SQL queries by fields of :serialize . You need to instantiate all the objects into Ruby, and check them one by one, which is slow (although it can be done in one line of code). -- Posted via http://www.ruby-forum.com/.
I''ve jsut made a blog post on a quick-and-dirty way to do the querying using the ''serialize'' column: http://www.karmiccoding.com/articles/2005/11/29/querying-serialized-data-in-activerecord Not brilliant, and more or less untested, but better than pulling all of the data from the server and parsing it application side. Very simple to turn into a plugin, too. Cheers! -DF On 11/29/05, List Recv <listrecv-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> garrick.vanburen wrote: > > I think this already exists as :serialize > > > > You can''t do SQL queries by fields of :serialize . You need to > instantiate all the objects into Ruby, and check them one by one, which > is slow (although it can be done in one line of code). > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Hi, As far as I know there is no one working on this but I would love to see an addition like this to rails. On 11/29/05, List Recv <listrecv-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Anyone work on, or interested in, a acts_as_hash? > > It would allow things like > > product.properties[''isbn''] = 32232323 > product.properties[''color''] = ''blue'' > product.save > id = product.id > > .... > > p = Product.find(id) > p[''color''] #=> ''blue'' > > ... > > Product.hashfind_by_properties(''isbn'', 32232323) #=> p > > > It''s useful when the properties you need to store are always changing, > so you can''t use field mapping, but you want to query by them, and so > can''t use serializable. > > Comments? Suggestions? Criticisms? > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Cheers, Peter Donald