Рубиновая вложенная форма

На самом деле, при сохранении он должен сохранить, но я получаю сообщение об ошибке и пытался выяснить, где я сделал ошибку.

Пожалуйста, помогите мне с этой ошибкой.

Заранее спасибо.

контроллер

def new
  @fooditem = Fooditem.new
  3.times { @fooditem.fooditemprices.build}
end

#Creating Food Items
def create
    @fooditem = Fooditem.new(fooditem_params)
    if @fooditem.save
        flash[:success] = "Food item created successfully."
        redirect_to fooditems_path
    else
        render 'new'
    end
end

Модель (ы)

class Fooditem < ApplicationRecord
  has_many  :fooditemprices, dependent: :destroy
  accepts_nested_attributes_for :fooditemprices, reject_if: lambda {|attributes| attributes['price'].blank?}, allow_destroy: true
end

class Fooditemprice < ApplicationRecord
  belongs_to :fooditem

  validates :size, presence: { message: "Size must exists." }
  validates :price, presence: { message: "Price must exists." }
end

Данные формы

<%= f.fields_for :fooditemprices do |ftp_form| %>
 <div class="col-sm-9 row col-sm-offset-3">
   <div class="col-sm-3">  
     <%= ftp_form.select :size, ["Full", "Half", "Small", "Medium", "Large"].collect { |p| [p, p] },{}, {class: "form-control"} %>
   </div>     
   <div class="col-sm-3">
      <%= ftp_form.number_field :price, placeholder: "Price", class: "form-control" %>
   </div>
   <div class="col-sm-3">      
      <%= ftp_form.number_field :weight, placeholder: "Weight", class: "form-control" %>
   </div>                
   <div class="col-sm-3">               
      <%= ftp_form.select :weight_in, ["Grams", "ml"].collect { |p| [p, p] },{}, {class: "form-control"} %>
   </div>
  </div>
<% end -%>

ошибка

fooditem must exist

Полученные параметры

"fooditem"=>{"name"=>"Food Item Name",
              "bdescription"=>"Food Item description of brief",
              "ddescription"=>"Food Item description of detailed",
              "priority"=>"1",
              "foodtype_id"=>"1",
              "foodcategory_id"=>"1",
              "fooditemprices_attributes"=>{
                    "0"=>{"size"=>"Full", "price"=>"120", "weight"=>"200", "weight_in"=>"Grams"},
                    "1"=>{"size"=>"Full", "price"=>"80", "weight"=>"120", "weight_in"=>"Grams"},
                    "2"=>{"size"=>"Full", "price"=>"50", "weight"=>"60", "weight_in"=>"Grams"}},
              "sku"=>"",
              "active"=>"1"},
              "commit"=>"Create Food Item"}

Ответы на вопрос(1)

Ваш ответ на вопрос