ruby-on-railshashhidden-fields

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"

Solution

  • 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.