我已经有这个问题几天了,并查看了每个教程和堆栈溢出。我似乎无法解决。我似乎无法使用有效的嵌套属性。我收到此表单视图的错误。
**Form View**
<%= form_for @trip, :html => { :class => 'form-horizontal' } do |f| %>
<div class="control-group">
<%= f.label :start, :class => 'control-label' %>
<div class="controls">
<%= f.text_field :start, :class => 'text_field' %>
</div>
<div class="control-group">
<%= f.label :end, :class => 'control-label' %>
<div class="controls">
<%= f.text_field :end, :class => 'text_field' %>
</div>
<div class="control-group">
<% f.fields_for :driver do |d| -%>
<%= d.label :driver, :class => 'control-label' %>
<div class="controls">
<%= d.text_field :driver, :class => 'text_field' %>
</div>
模型:
class Trip < ActiveRecord::Base
attr_accessible :end, :start
belongs_to :driver
belongs_to :customer
accepts_nested_attributes_for :driver
end
class Driver < ActiveRecord::Base
attr_accessible :name
has_many :trips
end