I am passing a hidden field for a form to distinguish between views the request came from:
<%= hidden_field_tag("advanced", true)%>
Apparently true gets passed as a string. I tried different syntaxes like:
<%= hidden_field_tag "advanced", true %>
<%= hidden_field_tag "advanced" => true %>
<%= hidden_field_tag :advanced => true %>
It always gets translated to this
<input type="hidden" name="advanced" id="advanced" value="true" />
Obviously, I can check the string value in the controller, but is this the expected behaviour?
Rails translate your parameters to the equivalent html, and it is only possible to have strings in html. The hidden_field_tag
is just a hidden text_field_tag
, so the value need to be text. And in the url you also have a string. So the conversion need to be done in the controller.