0

错误:未知属性:size_id

项目型号

has_many :sizeables
has_many :sizes, through: :sizeables, :dependent => :destroy

accepts_nested_attributes_for :sizes,  :reject_if => lambda { |a| a.values.all?(&:blank?) }, :allow_destroy => true 

尺寸型号

has_many :sizeables
has_many :items, through: :sizeables

has_one :centimeter
accepts_nested_attributes_for :centimeter,  allow_destroy: true

厘米型号

belongs_to :size

物品控制器

def new 
    @item = Item.new
    @size = @item.sizes.build
    @size.build_centimeter  
end

项目新视图

<%= f.fields_for :sizes do |s| %>
<%= s.fields_for :centimeter do |c| %>
<%= c.text_field :height %>
<% end %>
<% end %>

错误:未知属性:size_id

4

0 回答 0