【发布时间】:2012-05-10 06:30:03
【问题描述】:
鉴于以下情况:
型号
class Location < ActiveRecord::Base
has_many :games
end
class Game < ActiveRecord::Base
validates_presence_of :sport_type
has_one :location
accepts_nested_attributes_for :location
end
控制器
def new
@game = Game.new
end
查看(表单)
<%= simple_form_for @game do |f| %>
<%= f.input :sport_type %>
<%= f.input :description %>
<%= f.simple_fields_for :location do |location_form| %>
<%= location_form.input :city %>
<% end %>
<%= f.button :submit %>
<% end %>
为什么位置字段(城市)没有显示在表单中?我没有收到任何错误。我错过了什么?
【问题讨论】:
标签: ruby-on-rails-3 nested-attributes simple-form