public
Description: Sequel Model plugin to implicitly set created_at and updated_at
Clone URL: git://github.com/bricooke/sequel_timestamped.git
Search Repo:
100644 31 lines (24 sloc) 0.539 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
If your model is :timestamped, it will automatically set the
:created_at and :updated_at columns if they exist
 
With a migration like:
 
class MessageMigration < Sequel::Migration
  def up
    create_table :messages do
      primary_key :id
      integer :user_id
      string :name
      boolean :direct
      datetime :created_at
      datetime :updated_at
    end
  end
 
  def down
    execute "DROP TABLE messages"
  end
 
end
 
a class with
 
class Message < Sequel::Model
  is :timestamped
  belongs_to :user
end
 
will be autotimestamped