Rails3 form_for hidden_​​field undefined method'merge' [英] Rails3 form_for hidden_field undefined method 'merge'

查看:191
本文介绍了Rails3 form_for hidden_​​field undefined method'merge'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在一个form_for中放置一个hidden_​​field在一个ActionView帮助程序错误黄瓜崩溃。还有关于FixNum的漏洞,因为我还没有挖通过源代码。我的prices_controller显示:

My attempt to place a hidden_field within a form_for is crashing within cucumber on an ActionView helper error. Something also about FixNum which escapes me since I haven't dug through the source code. My prices_controller shows this:

 @price = Price.new
  @commodity = Commodity.find(params[:id])

我想用这个hidden_​​field建立价格和商品之间的链接:

I want to make the link between price and commodity with this hidden_field:

 <%= form_for (@price), :url => prices_path  do |f| %>
  <% f.hidden_field :commodity_id, @commodity.id %>
 .
 .
 <div class="actions">
 <%= f.submit "Submit" %>
   </div>

看到form_for api和上述应该工作。阅读stackoveflow上的其他回复,我已经把hidden_​​field在自己的div内的形式,添加了一个Hidden_​​field_tag,并将其放在提交行之前的行动div。看看合并msg,我想它不喜欢的东西关于这一行,但它似乎确定我。商品_id字段是匹配字段,sam

Looked at the form_for api and the above should work. Reading other replies on stackoveflow, I have put the hidden_field in its own div within the form, added a Hidden_field_tag, and placed it within the actions div before the submit line. Looking at the merge msg, I guess it doesn't like something about the line, but it appears OK to me. The commodity_id field is the match field, sam

推荐答案

如果您可以粘贴错误消息本身, ,它可以帮助我们。现在,我唯一看到的是 f.hidden_​​field 之前的ERB标记应该是<%= 我不确定,因为我不使用ERB。对于什么值,merge通常与 Hash 对象一起使用。也许它可以指向正确的方向

If you could paste the error message itself, and the relevant lines of the trace, it could help us. Right now, the only thing I see is that the ERB tag before f.hidden_field should be <%=, and I'm not sure about it since I don't use ERB. For what it's worth, merge is usually used with Hash objects. Maybe it can point you in the right direction

编辑确定我明白了。你必须写 f.hidden_​​field:commodity_id,:value => @ commodity.id

EDIT Ok I get it. You have to write f.hidden_field :commodity_id, :value => @commodity.id.

这篇关于Rails3 form_for hidden_​​field undefined method'merge'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆