Rails多记录表单返回:Array的未定义方法`model_name':Class

时间:2014-03-15 16:38:49

标签: ruby-on-rails-4

1 个答案:

答案 0 :(得分:1)

为什么[@mappings_list,@ mayppings_batch]?这是错的!你还有很多其他的错误。

正确的解决方案是:

<%= form_for @mappings_list do |f| %>

    <%= f.fields_for :mappings do |m| %>
      <div class="row">
        <div class="span2 field"> <%= m.text_field :source_code, :disabled => true %>
        </div>
        <div class="span2 field"> <%= m.text_field :source_caption, :disabled => true %>
        </div>   
        <div class="span2 field"> <%= m.collection_select :target_caption, @target_values, :value_caption, :value_caption %>
        </div>
      </div>
      <hr/>
    <% end %>
  <% end %>

  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

别忘了:

class MappingsList < ActiveRecord::Base
  ...
  accepts_nested_attributes_for :mappings