[Solved-4 Solutions] Rails hidden field undefined method 'merge' error
Error Description:
Rails hidden field undefined method 'merge' error
Solution 1:
- We should do:
- hidden_field expects a hash as a second argument
- we are using a hidden_field instead of a hidden_field_tag. Because we are using the non-_tag version, it is assumed that our controller has already set the value for that attribute on the object that backs the form.
For example:
controller:
view:
Solution 2:
We should do:
- hidden_field expects a hash as a second argument
Solution 3:
- By the way, we don't use hidden fields to send data from server to browser. Data attributes are awesome. We can do
- And then get attribute value with jquery
Solution 4:
- A version with the new syntax for hashes in ruby 1.9: