Displaying an objects properties different from default behavior in form helper rails

How can I go about displaying the :cords property below as a formatted array itself? and not just it's values. Given the form below:

<%= form_for @group do |f| %>
    <p>
        <%= f.label :name %><br>
        <%= f.text_field :name %>
    </p>
    <p>
        <%= f.label :cords %><br>
        <%= f.text_field :cords, name: "group[cords]" %>
    </p>
    <p>
        <%= f.label :members %><br>
        <%= f.text_field :members %>
    </p>
    <p>
        <%= f.submit %>
    </p>
<% end %>

When editing the object, I'd get something like

enter image description here

But what I want to see is the full raw data, like so:

enter image description here

I think this can be done with to_s, but i'm not sure how to go about getting this behavior

1 answer

  • answered 2017-06-17 19:30 Sebastián Palma

    You could try using an input tag instead text_field helper:

    <input type="text" name="group[cords]" value="<%= group.cords %>">