D
D
diem12017-01-10 15:08:23
Ruby on Rails
diem1, 2017-01-10 15:08:23

How to pass information from a form as an object?

In rails, you can collect information from several fields into an array in this way:
view:

<%= text_field_tag 'dogs[]' %>
<%= text_field_tag 'dogs[]' %>

controller:
puts params[:dogs] # => ["Bailey", "Max"]
How can I pass information from forms to the controller as an object?
for example: language - dropdown list, translation - text field. That is, the fields are the dynamic
structure of the transferred object:
{
  "ru": "собака",
  "en": "dog"
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Demidenko, 2017-01-10
@Dem1

<%= text_field_tag 'dogs[ru]' %>
<%= text_field_tag 'dogs[en]' %>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question