You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While I don’t think it’s possible to generate the address structure from the schema, it’s possible to initialize the address structure by yourself using the after_initialize callback:
classUser < ApplicationRecordafter_initializedo |user|
# If the address is nil, set it to a blank structureuser.address ||= {city: nil,postcode: nil}endend
@remi I thought we could somehow generate it from the existing JSON structure itself, without hardcoding. But I think it's not possible as of now. Thank you for the support.
I have a
user
model withaddress
field asjsonb
column.Now if I initialize the object it will show the jsonb attribute as
nil
But is it possible to generate the
address
structure from existingjson_schema
. so it will show like a normal object but nested like belowThank you
The text was updated successfully, but these errors were encountered: