渲染时名称错误

时间:2017-11-07 05:04:08

标签: ruby-on-rails

我需要在主窗体中渲染子窗体,并尝试在主窗体中渲染它

这个问题与三个模型有关

Class PrdItem model< ActiveRecord::Base

  has_one :prd_allisland_flat_delivery, dependent: :destroy, inverse_of: :prd_item
  accepts_nested_attributes_for   :prd_allisland_flat_delivery, allow_destroy: true

  has_many :prd_province_vise_deliveries,  dependent: :destroy, inverse_of: :prd_item
  accepts_nested_attributes_for   :prd_province_vise_deliveries, allow_destroy: true
end


Class PrdAllislandFlatDelivery < ActiveRecord::Base
   belongs_to :prd_item
end

Class PrdProvincevisedelivery < ActiveRecord::Base      
  belongs_to :prd_item
end

prd_item/new.html.erb _form.html.erb呈现

在那_form.html.erb  我写了这段代码片段

<%=  p.fields_for :prd_allisland_flat_deliveries  do |i| %>
  <%= render(:partial => 'prd_allisland_flat_delivery_field', :locals => {:f => p})%>
<% end %>

这是部分

形式的片段
   <div class="col-md-4">
      <%= f.text_field(:delivery_period, {placeholder: '0', class: 'form-control input_border input_field_text_align_right'})%>
    </div>

给了我

未定义的方法

  

`delivery_period&#39;对于#

错误

1 个答案:

答案 0 :(得分:0)

_form.html.erb

中的

<%=  p.fields_for :prd_allisland_flat_deliveries  do |i| %>
  <%= render(:partial => 'prd_allisland_flat_delivery_field', :locals => {:f => i})%>
<% end %>

<%= f.text_field(:delivery_period, {placeholder: '0', class: 'form-control input_border input_field_text_align_right'})%>