Rails hidden field undefined method 'merge' error

Jake picture Jake · Jul 9, 2011 · Viewed 81.3k times · Source

I wanna do something like this in rails

Here is what I have so far in rails:

<%= form_for @order do |f| %>
  <%= f.hidden_field :service, "test" %>
  <%= f.submit %>
<% end %>

But then I get this error:

undefined method `merge' for "test":String

How can I pass values in my hidden_field in rails?

Answer

apneadiving picture apneadiving · Jul 9, 2011

You should do:

<%= f.hidden_field :service, :value => "test" %>

hidden_field expects a hash as a second argument