Rails 隐藏字段未定义方法“合并"错误 [英] Rails hidden field undefined method 'merge' error
本文介绍了Rails 隐藏字段未定义方法“合并"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 Rails 中做这样的事情
I wanna do something like this in rails
这是我目前在 Rails 中的内容:
Here is what I have so far in rails:
<%= form_for @order do |f| %>
<%= f.hidden_field :service, "test" %>
<%= f.submit %>
<% end %>
但后来我收到此错误:
undefined method `merge' for "test":String
如何在 rails 的 hidden_field 中传递值?
How can I pass values in my hidden_field in rails?
推荐答案
你应该这样做:
<%= f.hidden_field :service, :value => "test" %>
hidden_field
需要一个散列作为第二个参数
hidden_field
expects a hash as a second argument
这篇关于Rails 隐藏字段未定义方法“合并"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文