Reputation: 11
I am setting my form like this:<%= hidden_field :room_name, @room.name %>
in my View I am getting the parameter as
room_name: !ruby/object:ActionController::Parameters parameters: !ruby/hash:ActiveSupport::HashWithIndifferentAccess Standard Apartment: ''
I just want to get the Standard Apartment Value
Upvotes: 1
Views: 3347
Reputation: 7777
If you declared a form with object like
<%= form_for(@room, html: {role: "form"}) do |f| %>
here f
is a form object then input field with value
will look like this
<%= f.hidden_field :room_name, value: @room.name %>
the output HTML is something like this
<input value="Room Name" type="hidden" name="room[room_name]" id="room_room_name">
If your form declared without object then it will be
<%= hidden_field_tag :room_name, value: @room.name %>
Hope it will help other SO user in the future.
Upvotes: 1
Reputation: 11
I figured it out changing my form to this
<%= hidden_field_tag "room_name",@room.name %>
Upvotes: 0