You should do:
<%= f.hidden_field :service, :value => "test" %>
hidden_field
expects a hash as a second argument
You are using a hidden_field instead of a hidden_field_tag. Because you are using the non-_tag version, it is assumed that your controller has already set the value for that attribute on the object that backs the form. For example:
controller:
def new
...
@order.service = "test"
...
end</pre>
view:
<%= form_for @order do |f| %>
<%= f.hidden_field :service %>
<%= f.submit %>
<% end %>
It works fine in Ruby 1.9 & rails 4
<%= f.hidden_field :service, value: "test" %>
A version with the new syntax for hashes in ruby 1.9:
<%= f.hidden_field :service, value: "test" %>
This also works in Rails 3.2.12:
<%= f.hidden_field :service, :value => "test" %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With