So, in HTML, if I made this form:
<form method="post">
<input type="text" name="categories[][name]" />
<input type="text" name="categories[][name]" />
<input type="text" name="categories[][name]" />
<input type="text" name="categories[][name]" />
<input type="submit" value="submit" />
</form>
I expect to params[:categories]be
[{"name"=>"value"},{"name"=>"value"},{"name"=>"value"},{"name"=>"value"}]
But instead, rails 2 will raise a TypeError: the expected Hash (received array) for param
Here an error occurs:
http://apidock.com/rails/Rack/Utils/normalize_params
Why is this not permitted or not handled on rails? What am I missing?
I know that I could index the input like this:
<input type="text" name="categories[0][name]" />
<input type="text" name="categories[1][name]" />
<input type="text" name="categories[2][name]" />
<input type="text" name="categories[3][name]" />
And get the hash. But that seems counterproductive.
source
share