0
所以我使用Rails 3.2.11的nested_form(根据Gemfile.lock的v0.3.2)。我有一个带有类别字段的服务模型,最初可以采用多个可通过选择下拉列表输入的值。什么可能导致nested_form不输出正确的选定输入值?
类别是这样的:[“Ĵ奖”,“Z奖”,“其他”]
当我去保存表单字段为J奖(或Z奖)的值和重新呈现一个可编辑的表单,表单将重新显示值为“其他”的类别。然而,如果我走进轨道控制台并查看保存的服务模型的类别字段,它会显示“J Award”。
这可能是什么原因造成的?由于nested_form不再维护,我应该放弃并以不同的方式处理多个模型?重新呈现形式的
HAML输出
= semantic_nested_form_for @service, :url => "/update", :html => { :class => "service", :autocomplete => "off" } do |f|
%h1.page-title Service
.page-wrapper
= render :partial => "shared/error_messages", :locals => { :object => @service }
重新呈现形式的HTML输出:
<li class="string input required stringish" id="service_category_input"><label class=" label" for="service_category">Category<abbr title="required">*</abbr></label><input id="service_category" maxlength="255" name="service[category]" type="text" value="J Award" />
</li>
= f.inputs do
%h3 Project Information
= f.input :billable, :as => :radio, :collection => { 'Billable' => true, 'Non-billable' => false }, :label => 'Category', :input_html => { :disabled => true }
= f.input :category
= f.input :assigned_consultant, :input_html => { :readonly => true }
= f.input :aims, :input_html => { :readonly => true }