I want to create a general model ''Product'' that I will be able to store several attributes in it. For example the attributes :id :name :description are pretty stantard. So each product will have this attributes. However, I wanted to know if it is possible to create dynamic attributes. In the case of a cell phone device I might want to store the IMEI of the phone, this attribute is useless if the product is a laptop. Is there any whey to create dynamic attributes ? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
You may look into Single table inheritance to see if that''ll suit your needs. Otherwise you could look into something like mongomapper and mongodb. On Jan 24, 11:51 pm, Demec <de...-ee4meeAH724@public.gmane.org> wrote:> I want to create a general model ''Product'' that I will be able to > store several attributes in it. > > For example the attributes > > :id > :name > :description > > are pretty stantard. So each product will have this attributes. > > However, I wanted to know if it is possible to create dynamic > attributes. > In the case of a cell phone device I might want to store the IMEI of > the phone, this attribute is useless if the product is a laptop. > > Is there any whey to create dynamic attributes ?-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Matt W. wrote:> You may look into Single table inheritance to see if that''ll suit your > needs.STI won''t do the trick here. Multiple-table inheritance might. Or you could have a separate Attribute model, or (ugly) put all the "extra" attributes into a serialized Hash. But really, you should probably have several different tables, not the undifferentiated Product.> Otherwise you could look into something like mongomapper and > mongodb.Or CouchDB. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
If you wanna search across this dynamic attributes, you might take a look at acts_as_solr_reloaded, it has support for dynamic attributes: http://github.com/dcrec1/acts_as_solr_reloaded you just need to run a migration: script/generate dynamic_attributes_migration and then define your model like this: acts_as_solr :dynamic_attributes => true This will anotate your model like: has_many :dynamic_attributes where DynamicAttribute is a class with name and value properties, like: DynamicAttribute.new :name => ''imei'', :value => ''123456-12-123456-1'' Then you can search like this: Product.search "imei:''123456-12-123456-1''" More info here: http://www.diegocarrion.com/2010/01/18/thinkingsphinx-exits-enters-actsassolrreloaded/ cheers On Jan 25, 4:23 pm, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Matt W. wrote: > > You may look into Single table inheritance to see if that''ll suit your > > needs. > > STI won''t do the trick here. Multiple-table inheritance might. > > Or you could have a separate Attribute model, or (ugly) put all the > "extra" attributes into a serialized Hash. > > But really, you should probably have several different tables, not the > undifferentiated Product. > > > Otherwise you could look into something like mongomapper and > > mongodb. > > Or CouchDB. > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Possibly Parallel Threads
- [dongle0] timedout while waiting 'OK' in response to 'AT'
- [dongle0] timedout while waiting 'OK' in response to 'AT'
- [dongle0] timedout while waiting 'OK' in response to 'AT'
- [dongle0] timedout while waiting 'OK' in response to 'AT'
- Best Mongo Framework to work with Rails