title: Datetime field using Rails on Postgres
body: <p>I'm using Rails to make a scheduling app with Postgres. I have a model Shift with two timedate columns, start_at and end_at. The migration to create it follows:</p>
  
  <pre><code>class CreateShifts &lt; ActiveRecord::Migration
    def change
      create_table :shifts do |t|
        t.references :user
        t.references :schedule
        t.datetime :start_at
        t.datetime :end_at
        t.string :position
        t.string :notes
  
        t.timestamps
      end
      add_index :shifts, :user_id
      add_index :shifts, :schedule_id
    end
  end
  </code></pre>
  
  <p>When I try to create a record I get the following error 500 output:</p>
  
  <pre><code>GError: ERROR:  column "end_at" is of type timestamp without time zone but expression is of type time without time zone at character 132
  HINT:  You will need to rewrite or cast the expression.
  : INSERT INTO "shifts" ("created_at", "end_at", "notes", "position", "schedule_id", "start_at", "updated_at", "user_id") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id"
  </code></pre>
  
  <p>I am creating a valid DateTime object before the DB save, because I've used the logger to display it and it is correct. The params look like this:</p>
  
  <pre><code>{"utf8"=&gt;"✓",
   "authenticity_token"=&gt;"qornHMTAdikZJP/sByPIg//fFuYHHAQH3M/0R9XnP+o=",
   "shift"=&gt;{"user_id"=&gt;"1",
   "start_at(1i)"=&gt;"2011",
   "start_at(2i)"=&gt;"11",
   "start_at(3i)"=&gt;"14",
   "start_at(4i)"=&gt;"00",
   "start_at(5i)"=&gt;"01",
   "end_at(1i)"=&gt;"2011",
   "end_at(2i)"=&gt;"11",
   "end_at(3i)"=&gt;"14",
   "end_at(4i)"=&gt;"00",
   "end_at(5i)"=&gt;"02",
   "position"=&gt;"",
   "notes"=&gt;""},
   "schedule_id"=&gt;"1"}
  </code></pre>
  
  <p>However, I can create a record via console by setting both fields to Time.now.</p>