当我使用accepts_nested_attributes_for
时,相应的字段不再显示在我的视图中。acceptable_nested_attributes_for保持表单域不会显示
class Survey < ActiveRecord::Base
has_many :questions
accepts_nested_attributes_for :questions
end
class Question < ActiveRecord::Base
belongs_to :survey
end
然后在我的观点:
<%= form_for @survey do |f| %>
<%= f.fields_for :questions do |question_fields| %>
<%= question_fields.text_area :text %>
<% end %>
<% end %>
如果我删除accepts_nested_attributes_for
那么text_area
节目,但如果我把它...什么都没有得到呈现。
我运行的Rails 3.0.3