collection_select 方法在 Rails 3.1.1 中给出错误
我有一个名为类别的模型和其他模型产品。他们有 has_many 和belongs_to 关系。 但在我看来,代码
<p><%= f.collection_select(:product, :category_id, Category.all, :id, :name)%>
给了我
undefined method `merge' for :name:Symbol
任何线索它有什么问题吗?
I have a Model called Category and other Model Product. They have has_many and belongs_to relation.
But code in my view
<p><%= f.collection_select(:product, :category_id, Category.all, :id, :name)%>
is giving me
undefined method `merge' for :name:Symbol
Any clue what is wrong with it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能会遇到这样的情况:
因为
f
已经与product
绑定在一起,因此您不需要将其包含为第一个参数,因此它应该是:或者,您不能使用
f.
:Chances are you have something like this:
Because
f
is already tied toproduct
, you don't need to include it as your first argument, so it should just be:Or, you could not use
f.
: