我有两个模型:newsavedmap 和航点。
我的新闻保存地图:
class Newsavedmap < ActiveRecord::Base
has_many :waypoints, :dependent => :destroy
accepts_nested_attributes_for :waypoints
end
该表单位于 maptry.html.erb 上
<% form_for @newsavedmap, :html=>{:id=>'createaMap'} do |f| %>
<%= f.error_messages %>
<%= f.text_field :name, {:id=>"savemap_name", :size=>30, :value=>"New Map"}%></p>
<%= f.fields_for :waypoints do |p| %>
<%= p.select :waypoint, itinerary.locations_for_select,{},{ :multiple=>"true", :id=>"waypoints", :class=>"mobile-waypoints-remove"}%>
<% end %>
<% end %>
出于某种原因,这会引发以下错误:
ActionView::TemplateError (compile error .../maptry.html.erb:392: syntax error, unexpected ')'
...ields_for :waypoints do |p| ).to_s); @output_buffer.concat ...
谢谢你的尽心帮助!
Rails 2 的最终工作版本
<% f.fields_for @waypoints do |p| %>
<%= p.select :waypoint, {},{}, :multiple=>"true", :id=>"waypoints", :class=>"mobile-waypoints-remove" %>
<% end %>