Sha256: 4062bc7f6335e7126590290a2c5dbfe34665077d72f6be6cffd3ba7fde4cdc6f

Contents?: true

Size: 624 Bytes

Versions: 2

Compression:

Stored size: 624 Bytes

Contents

class Timestamp < ActiveRecord::Base
  class << self
    def create_table
      self.connection.create_table(:timestamps) do |t|
        t.integer :timestampable_id
        t.string  :timestampable_type
        t.string  :key
        t.datetime    :stamped_at
        t.timestamps
      end
    end

    def drop_table
      self.connection.drop_table(:timestamps)
    end
  end

  belongs_to :timestampable, :polymorphic => true

  validates_presence_of :key, :timestampable_id, :timestampable_type
  validates_uniqueness_of :key, :scope => [ :timestampable_id, :timestampable_type ]

  def to_param
    self.key
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
seamusabshere-has_timestamps-1.5.5 lib/timestamp.rb
seamusabshere-has_timestamps-1.5.6 examples/timestamp.rb