I have a Rails model which has a database column of type "json":
create_table "games", force: true do |t|
t.json "game_board"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
Great! Now how do I use it? Is it really just as simple as treating the field like a Hash?
self.game_board[:player1] = 1
self.game_board[:cards] = cards.to_hash
If I were to write that, would everything just work as expected, so in a future API call from a client I could do this?:
self.game_board[:player] # And get back the 1 that I put here before
What about performance as well? Will the entire game_board be de-serialized every time even if that field is never read? Will the field be re-written (IOW a database write) each time I change part of the "Hash?"