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