jerome.lacoste-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Nov-02 19:33 UTC
DB: class to multiple rows mapping (aka rails ''osproperty'')
Hi, Has anyone implemented some sort of automatic class to dynamic table mapping ? The idea is to have a single table capable of storing various unrelated classes. Some sort of Extreme polymorphism. I''ve used this with other languages. E.g. osproperty in Java. The idea is the following In the DB create table dynamicobjects ( id int, object_type varchar(255), key_name varchar(255), value_type int, value_int int, value_char varchar(255), value_longchar text, ... primary key (id, object_type, key_name) ) then I could map any instance of any class to it. E.g. class User def initialize(firstname, lastname, birthdate) @firstname = firstname @lastname = lastname @birthdate = birthdate end end would end up being stored as multiple rows one for each instance property, all indexed with object_type = ''user'' and id = @user.id. I just wonder if this sort of design would be not fitting with the way rails works. Would that cause particular problems ? If that sounds OK, and nobody did it before, I am willing to try. Any hints on what I should try to use from the framework itself ? Cheers, Jerome --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Possibly Parallel Threads
- Index Searcher Causes GC Memory Error: "irb: double free or corruption"
- extract month from date column
- [ossh patch] principal name/patterns in authorized_keys2
- Trouble installing SWAT on a Samba 4 Alpha 13 build on Ubuntu Server
- [PATCH]: A daemon to support HyperV KVP functionality