Has Timestamps plugin

Plugin details

Rails plugin to add timestamps to ActiveRecord models.

Websitehttp://github.com/seamusabshere/has_timestamps Repositorygit://github.com/seamusabshere/has_timestamps.git Author Seamus Abshere Tags timestamp LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install git://github.com/seamusabshere/has_timestamps.git

Example
=======

class CreateTimestamps < ActiveRecord::Migration
  def self.up
    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 self.down
    drop_table(:timestamps)
  end
end


then...

class User < ActiveRecord::Base
  has_timestamps
end


>> user.timestamps
=> []
>> user.timestamp!(:hailed)
=> Wed Dec 10 15:11:52 -0500 2008
>> user.timestamps
=> [#]
>> user.timestamped?(:hailed)
=> true
>> user.save
=> true
>> user.timestamped?(:saluted)
=> false
>> user.timestamp!(:saluted)
=> Wed Dec 10 15:12:28 -0500 2008
>> user.timestamped?(:saluted)
=> true
>> user.timestamps[:saluted]
=> Wed Dec 10 15:12:28 -0500 2008
>> user.timestamps[:hailed]
=> Wed Dec 10 15:11:52 -0500 2008

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, 6 months ago