I'm playing with the Rails API server and I'm trying to pass a JSON object to the database, but it keeps resulting in a null value.
The schema is simple:
create_table "notes", force: :cascade do |t|
t.string "title"
t.string "created_by"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.json "clients"
end
Here's what I'm posting in Postman
{
"created_by": "1",
"title": "I'm another note",
"clients": {
"client1": {
"name": "name 1",
"role": "role 1"
},
"client 2": {
"name": "name 2",
"role": "role 2"
}
}
}
and this returns
{
"id": 14,
"title": "I'm another note",
"created_by": "1",
"created_at": "2017-06-14T10:52:00.226Z",
"updated_at": "2017-06-14T10:52:00.226Z",
"clients": null
}
If I send the client key/value pairs as "clients": "some client" it will write no problem. Am I just passing the wrong data in Postman or is it something else?