Why do hidden fields produce hashes?
My Hidden Field:
- @calc.results.each do |k, v|
= hidden_field :calc开发者_开发技巧_result, :value => "#{k[:total_interest]}"
Which returns :
"calc_result"=>
{"value214.14"=>"",
...
How can I write the hidden_field so that it produces :
"value" => "214.14"
You don't need to pass :value, just say this:
= hidden_field_tag :calc_result, "#{k[:total_interest]}"
That should get you what you want.
By using hidden_field
, the name attribute is interpreted from the field name (in this case :calc_result
.
If value
is not a field in the model, you could use hidden_field_tag
instead.
= hidden_field_tag "value", k[:total_interest]}
精彩评论