2013-11-01 98 views
1

我想從另一個模型獲取集合選擇,並且我不斷收到上述錯誤。到處看,得到鐵軌投下,但沒有任何意義。語法錯誤,意外',',期待')'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 

搜索無處不在,我就想不通出來。它一定是愚蠢的。

+0

我經歷了它,一切似乎正確。似乎沒有任何開放。 – McDoku

回答

3

錯誤是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 = {}) 
相關問題