Damian Rr wrote:
second: the users should be able to add new fields to that model, for
example: the model 'person' may have 2 fields, let say: 'name' and
'age', the basic idea is to give the user the ability to create new
fields like 'sex' and 'occupation' if he like to do so, i wouldn't like
to do ALTER TABLE to solve this .... any idea will be most welcome ...
I have a plugin that I developed that will help handle this problem. You can find out about it at:
It basically does what nathaniel described but also has some method_missing magic to allow you to do:
joe.gender = 'Male';
Even though "gender" is not a real attribute on the peoples table. It is still what I consider "beta" software but it has been used successfully in two project. I just need to clean up the documentation and then I probably consider it out of "beta".
Also as nathaniel said this will basically make your data not very accessible. Doing queries on these dynamic fields is difficult. But it is nice when you need to be able to just store and retrieve a bunch of data.