Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use Sequel Timestamps plugin to generated created_at and updated_at

  • Loading branch information...
commit c893de2ad7dee842cf8cc9ea6b33658cc3aa833c 1 parent 85aeb12
@dmac authored
Showing with 2 additions and 13 deletions.
  1. +2 −13 lib/db.rb
View
15 lib/db.rb
@@ -2,19 +2,8 @@
require "pathological"
require "environment"
-class Sequel::Model
- def before_create
- now = Time.now
- self.created_at ||= now if self.columns.include?(:created_at)
- self.updated_at = now if self.columns.include?(:updated_at)
- super
- end
-
- def after_save
- super
- self.updated_at = Time.now if self.columns.include?(:updated_at)
- end
-end
+# Timestamp all models with created_at and updated_at.
+Sequel::Model.plugin :timestamps
DB = Sequel.postgres(:host => DB_HOST, :user => DB_USER, :password => DB_PASS, :database => DB_NAME)
Please sign in to comment.
Something went wrong with that request. Please try again.