In My Phoenix (Elixir) App I have a board
field in a table as an array of strings ({:array, :string}
) with a default value of ["", "", "", "", "", "", "", "", ""]
.
However, when I update using ecto only one cell in the 9-element array, the entire board
field in the database is being replaced with a single-element array — for example:
{"X"}
instead of the expected:
{"X", "", "", "", "", "", "", "", ""}
current_board = game.board || List.duplicate(“”, 9)
new_board = List.replace_at(current_board, position, player_symbol)
board in migration file
add :board, {:array, :string}, default: [“”, “”, “”, “”, “”, “”, “”, “”, “”]
board in schema file
field :board, {:array, :string}, default: List.duplicate(“”, 9)
need help please