I am trying to get a collection select from an another model and I keep getting the above error. Looked everywhere, got rails casts but nothing makes sense.
_form.rb
<%= f.label :city %><br />
<%= f.collection_select (:share ,:city_id, City.all , :id, :name ) %>
It highlights 'form' on the error report
<h1>New share</h1>
<%= render 'form' %>
<%= link_to 'Back', shares_path %>
Here are my models...
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
Searched everywhere and I cannot figure it out. It must be something silly.
The error is the whitespace after collection_select
.
<%= f.collection_select(:city_id, City.all , :id, :name) %>
or
<%= f.collection_select :city_id, City.all , :id, :name %>
EDIT :
Taking into account that :share
is your object, I have removed it (see above). The first param is the method:
collection_select(method, collection, value_method, text_method, options = {}, html_options = {})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.