title: Add Rows to a SQL Table in Ruby on Rails
body: <p>How do I add data to a table in Rails?</p>
  
  <p>So far I have created a Rails app that pulls in data from an API. Next, I have ran the command</p>
  
  <pre><code>rails generate model order
  </code></pre>
  
  <p>and I have /db/migrate/timestamp_create_orders.rb</p>
  
  <pre><code>class CreateOrders &lt; ActiveRecord::Migration
    def change
      create_table :orders do |t|
        t.string :email, null: false
        t.string :order_date, null: false
        t.string :total_price, null: false
        t.string :order_number, null: false
        t.string :cust_name, null: false
        t.string :zip_code, null: false
  
        t.timestamps null: false
      end
    end
  end
  </code></pre>
  
  <p>Next, I believe I need to run db:migrate and that will create the table.</p>
  
  <p>My question is, how do I add data to this table? I want the user to visit the app, it pulls in the data, and stores it in this table.</p>
  
  <p>I have found conflicting advice..
  Should I just use the advice from <a href="https://stackoverflow.com/questions/4614550/rails-add-new-row-in-table">here</a></p>
  
  <pre><code>Order.create(:email=&gt;'fake@fake.com',:order_data=&gt;"... 
  </code></pre>
  
  <p>But other advise seems to say not to do this <a href="https://stackoverflow.com/questions/2667580/how-do-i-add-some-inserts-in-rails-migration">here</a> and <a href="https://stackoverflow.com/questions/10534682/how-can-i-insert-data-into-table-by-the-help-of-migration-and-that-table-is-gene">here</a>. Though they are all pretty old</p>