Skip to content

Instantly share code, notes, and snippets.

@mAlishera
Created January 23, 2017 22:35
Show Gist options
  • Save mAlishera/a7f9c3fefe5249406ac498553da4b3fd to your computer and use it in GitHub Desktop.
Save mAlishera/a7f9c3fefe5249406ac498553da4b3fd to your computer and use it in GitHub Desktop.
timestamps in AR
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
...
t.datetime 'inserted_at', null: false
t.datetime 'updated_at', null: false
end
end
end
class User < ActiveRecord::Base
private
def timestamp_attributes_for_create
[:inserted_at]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment