[英]syntax error, unexpected ',', expecting ')' RoR
我试图从另一个模型中选择一个集合,我不断收到上述错误。 无处不在,看到了铁轨,但没有任何意义。
_form.rb
<%= f.label :city %><br />
<%= f.collection_select (:share ,:city_id, City.all , :id, :name ) %>
它突出显示错误报告中的“表单”
<h1>New share</h1>
<%= render 'form' %>
<%= link_to 'Back', shares_path %>
这是我的模特......
class Share
include Mongoid::Document
field :name, type: String
field :type, type: String
field :summary, type: String
field :description, type: String
field :city, type: String
embedded_in :city
has_many :category
end
class City
include Mongoid::Document
embedded_in :share
field :name, type: String
field :country, type: String
attr_accessible :name, :city_id, :id
end
到处搜索,我无法弄清楚。 一定是傻事。
错误是collection_select
之后的空白。
<%= f.collection_select(:city_id, City.all , :id, :name) %>
要么
<%= f.collection_select :city_id, City.all , :id, :name %>
编辑 :
考虑到:share
是你的对象,我已将其删除(见上文)。 第一个参数是方法:
collection_select(method, collection, value_method, text_method, options = {}, html_options = {})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.