I have a column on my model User called properties which is jsonb. As i have the requirement for user generated dynamic fields.
How would you access the attributes as if they were normal mapped columns
E.g User model has a column called first_name but a property in the properties called eye_color
user = User.find(1)
user.first_name # => "john"
# to access the eye color you would do
user.properties['eye_color'] # => "green"
What I would like to do is to be able to call the map json attribute so i can set and get it via like bellow
user.eye_color = 'green'
This needs to be dynamically done as the field attributes can change. However, at the user instance I can see work out what all the attributes will be.