I have a serialized Array field in my model called :cords, and part of my form looks like so:
<%= form_for @group do |f| %>
....
<p>
<%= f.label :cords %><br>
<%= f.text_field :cords, name: "group[cords][]" %>
</p>
....
Then inside my controller, I attempt to use it like so
@group = Group.new(params.require(:group).permit(:name, :members, cords: [] ))
if @group.save
redirect_to @group
else
render 'new'
end
This doesn't seem to work though, because when I type in some array like [[1,2],[3,4]] I see the SQL insert is
INSERT INTO "groups" ("cords", "name", "members", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?) [["cords", "---\n- \"[[1,2],[3,4],[5.5,6]]\"\n"], ["name", "GG"], ["members", 55], ["created_at", "2017-06-12 02:13:37.462355"], ["updated_at", "2017-06-12 02:13:37.462355"]]
Why is cords submitted as ["cords", "---\n- \"[[1,2],[3,4],[5.5,6]]\"\n"]? I believe I'm doing something wrong with my actual form setup
paramsthat are coming in the server log.<%= f.text_field "group[cords][]" %>instead