title: how can I add food id to my order?
body: <p>currently I am making a simple restaurant application by rails. Now, when I click on the button order (on the same row with the food item), it will lead me to the create new order page, but the thing is the order doesn't belong to any food because I don't know how to integrate the food id to the form of the order. Do I need to create another model like order_item to accomplish the task? Because later, I want to add the quantity for the food, and the ability for the user to order multiple food items at the same time(like a cart). By the way is there any gem that I can use in this situation? I looked at the spree gem, but I dont know whether  the gem is appropriate for my application?
  Here are all the files:</p>
  
  <p><a href="https://i.stack.imgur.com/z7LPw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z7LPw.png" alt="Menu Page"></a></p>
  
  <p><strong>menu/drink.html.erb</strong>:</p>
  
  <pre><code>&lt;ul class="nav nav-tabs"&gt;
    &lt;li class="nav-item"&gt;
      &lt;%= link_to "Breakfast", menu_breakfast_path, class: "nav-link" %&gt;
    &lt;/li&gt;
    &lt;li class="nav-item"&gt;
      &lt;%= link_to "Lunch", menu_lunch_path, class: "nav-link" %&gt;
    &lt;/li&gt;
    &lt;li class="nav-item"&gt;
      &lt;%= link_to "Dinner", menu_dinner_path, class: "nav-link" %&gt;
    &lt;/li&gt;
    &lt;li class="nav-item"&gt;
      &lt;%= link_to "Drinks", menu_drink_path, class: "nav-link active" %&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
  &lt;table class="table table-inverse sortable" &gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;&lt;%= sortable "Name" %&gt;&lt;/th&gt;
        &lt;th&gt;Description&lt;/th&gt;
        &lt;th&gt;&lt;%= sortable "Price" %&gt;&lt;/th&gt;
        &lt;th&gt;Order&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;% @foods.each do |food| %&gt;
      &lt;tbody&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;%= link_to food.name, food %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= food.description %&gt;&lt;/td&gt;
          &lt;td&gt;$&lt;%= food.price %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= link_to "Order", new_order_path, class: "btn btn-primary" %&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;% end %&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p><strong>order/_form.htm.erb</strong>:</p>
  
  <pre><code>&lt;%= form_for(@order) do |f| %&gt;
    &lt;% if @order.errors.any? %&gt;
      &lt;div id="error_explanation"&gt;
        &lt;h2&gt;&lt;%= pluralize(@order.errors.count, "error") %&gt; prohibited this order from being saved:&lt;/h2&gt;
  
        &lt;ul&gt;
        &lt;% @order.errors.full_messages.each do |message| %&gt;
          &lt;li&gt;&lt;%= message %&gt;&lt;/li&gt;
        &lt;% end %&gt;
        &lt;/ul&gt;
      &lt;/div&gt;
    &lt;% end %&gt;
  
    &lt;div class="field"&gt;
      &lt;%= f.label :coupon %&gt;&lt;br&gt;
      &lt;%= f.text_field :coupon %&gt;
    &lt;/div&gt;
  
    &lt;div class="field"&gt;
      &lt;%= f.label :name %&gt;&lt;br&gt;
      &lt;%= f.text_field :username %&gt;
    &lt;/div&gt;
    &lt;div class="field"&gt;
      &lt;%= f.label :phone %&gt;&lt;br&gt;
      &lt;%= f.telephone_field :phone %&gt;
    &lt;/div&gt;
    &lt;div class="field"&gt;
      &lt;%= f.label :address %&gt;&lt;br&gt;
      &lt;%= f.text_field :address %&gt;
    &lt;/div&gt;
    &lt;div class="actions"&gt;
      &lt;%= f.submit %&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>orders_controller.rb:</p>
  
  <pre><code>def new
      @order = Order.new
    end
  def create
      @order = Order.new(order_params)
  
      respond_to do |format|
        if @order.save
          format.html { redirect_to order_path, notice: 'Order was successfully created.' }
          format.json { render :show, status: :created, location: @order }
        else
          format.html { render :new }
          format.json { render json: @order.errors, status: :unprocessable_entity }
        end
      end
    end
  </code></pre>
  
  <p><strong>order.rb</strong>:</p>
  
  <pre><code>class Order &lt; ActiveRecord::Base
    has_many :foods
  end
  </code></pre>
  
  <p><strong>food.rb</strong>:</p>
  
  <pre><code>class Food &lt; ActiveRecord::Base
    belongs_to :section
    belongs_to :order
  end
  </code></pre>