Ruby on rails 3 奇怪的未定义方法';全部';和集合\u选择错误
我有一个这样的表格(简化了,但你明白了): 在Ruby on rails 3 奇怪的未定义方法';全部';和集合\u选择错误,ruby-on-rails-3,nested-attributes,Ruby On Rails 3,Nested Attributes,我有一个这样的表格(简化了,但你明白了): 在集合中选择行 模板。所有都通过控制器和控制台工作。如果我写了一个@templates=Template.all并在集合中使用@templates选择行,那么我会得到以下错误: undefined method `merge' for :name:Symbol 有什么想法吗?解决了。这是令人烦恼的简单 <%= price.collection_select(:template_id, @templates, :id, :name) %>
集合中选择行
模板。所有
都通过控制器和控制台工作。如果我写了一个@templates=Template.all
并在集合中使用@templates
选择
行,那么我会得到以下错误:
undefined method `merge' for :name:Symbol
有什么想法吗?解决了。这是令人烦恼的简单
<%= price.collection_select(:template_id, @templates, :id, :name) %>
重复。嗯。解决了它。这是令人烦恼的简单
<%= price.collection_select(:template_id, @templates, :id, :name) %>
重复。嗯。你可以在前面加两个冒号。e、 g,
<%= price.collection_select(:price, :template_id, ::Template.all, :id, :name) %>
但是我认为,您应该避免使用模板作为模型名,因为它是rails您可以通过在前面加两个冒号来实现。e、 g,
<%= price.collection_select(:price, :template_id, ::Template.all, :id, :name) %>
但我认为,您应该避免使用模板作为模型名称,因为它是rails一个选项是将模板作为实例变量公开(或作为发送到视图层的任何内容的一部分),并完全避免解决问题。一个选项是将模板作为实例变量公开(或作为发送到视图层的任何内容的一部分)并完全避免解决问题。