title: How to implement update controller method
body: <p>I am working on web app development using ruby on rails. I want to enable users to upload images for their favorite food. I have food_item model and a food_image model. In the food_item model:</p>
  
  <pre><code>has_many :food_images
  has_many :food_portions ＃this is the work done by another teammate
  </code></pre>
  
  <p>I also define in the food_item controller:</p>
  
  <pre><code>def food_item_params
    params.require(:food_items).permit(:name, :category, :description, food_images_attributes: [:id, :food_item_id, :avatar]).tap do |whitelisted|
    whitelisted[:portion] = params[:food_items][:portion]
    whitelisted[:price] = params[:food_items][:price]
  end
  </code></pre>