title: adding a date and time fields in a rails migration
body: <p>I'm trying to create an event, the event has a date and a time field. When creating the table for <code>protest</code> I didn't add a time field, so I had to run a migration to add a time field. But I am now having issues when creating the form. What is the elegant solution to create a time and date field?</p>
  
  <pre><code>class CreateProtests &lt; ActiveRecord::Migration[5.1]
    def change
      create_table :protests do |t|
        t.string :name
        t.text :description
        t.string :location
        t.datetime :starts_at
        t.references :creator, index: true, foreign_key: { to_table: :users }
      end
    end
  end
  </code></pre>
  
  <p>I then added a field for the time of day:</p>
  
  <pre><code>class AddStartsAtTimeOfDayToProtests &lt; ActiveRecord::Migration[5.1]
    def change
      add_column :protests, :starts_at_time_of_day, :datetime
    end
  end
  </code></pre>
  
  <p>protests/new.html.erb</p>
  
  <pre><code>&lt;div class="col-md-12"&gt;
    &lt;div class="card"&gt;
      &lt;div class="card-header"&gt;&lt;h2&gt;Create A Protest&lt;/h2&gt;&lt;/div&gt;
      &lt;div class="card-block"&gt;
  
      &lt;%= form_for(@protest, url: protests_path, html: {multipart: true}) do |f| %&gt;
        &lt;div class="form-group"&gt;
          &lt;%= f.label :name %&gt;
          &lt;%= f.text_field :name, autofocus: true, class: "form-control" %&gt;
        &lt;/div&gt;
  
        &lt;div class="form-group"&gt;
          &lt;%= f.label :description %&gt;
          &lt;%= f.text_area :description, class: "form-control" %&gt;
        &lt;/div&gt;
  
        &lt;div class="form-group"&gt;
          &lt;%= f.label :location %&gt;
          &lt;%= f.text_field :location, class: "form-control" %&gt;
        &lt;/div&gt;
  
        &lt;div class="form-group"&gt;
          &lt;%= f.label "Date:" %&gt;
          &lt;%= f.text_field :starts_at, value: "02/16/13", id: "dp2"%&gt;
        &lt;/div&gt;
  
  
  
       &lt;div class="form-group"&gt;
         &lt;%= f.label "Time:" %&gt;
         &lt;%= f.time_select :starts_at, ignore_date: true, class: "form-control"%&gt;
       &lt;/div&gt;
  
        &lt;div class="form-group"&gt;
          &lt;%= f.label :image %&gt;
          &lt;%= f.file_field :image, as: :file, class: "form-control" %&gt;
        &lt;/div&gt;
  
        &lt;div class="form-group"&gt;
          &lt;%= f.submit "Create", class: "btn btn-primary" %&gt;
        &lt;/div&gt;
      &lt;% end %&gt;
    &lt;/div&gt;
  
  
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>