Your circuit might look like this:
create_table "accounts", :force => true do |t| t.integer "user_id" t.string "data_key" t.string "data_value" end
Account model
belongs_to :user DATA_KEYS = ['age', 'birthdate', 'hair_color', 'height' ]
User model
has_many :accounts Account::DATA_KEYS.each do |method|
You can get and set account data values
eg. user.age => will return the age of the user
user.hair_color = 'brown' => set the hair color
shweta
source share