E
E
eldar_web2015-05-14 15:22:03
Ruby on Rails
eldar_web, 2015-05-14 15:22:03

How in Rails to accept the content of an input where name='address[1]' ???

For example, there are fields:

<input type='text' name='address[1]' />
<input type='text' name='address[2]' />

How in the controller to accept the value address[1] ???
This is not how params[:address][1] works...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Shaks, 2015-05-14
@eldar_web

you don't have to do that! It is necessary to accept all data through strong parameters
something like this:
the field must have the name name="model[address][]" value="1"
-----------------
But in answer to your question

pp params[:address]['1'] # => 'asdf'
# "address"=>{"1"=>"asdf"}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question