infused / blame

Blame is a simple alternative to the userstamp plugin for Rails, which adds userstamps to ActiveRecord models

This URL has Read+Write access

blame /
name age message
file MIT-LICENSE Wed Oct 08 15:02:33 -0700 2008 Giving birth to a new plugin [infused]
file README.md Loading commit data...
file Rakefile Wed Oct 08 15:02:33 -0700 2008 Giving birth to a new plugin [infused]
file about.yml
file init.rb Wed Oct 08 15:02:33 -0700 2008 Giving birth to a new plugin [infused]
directory lib/
directory test/
README.md

Blame

Automatically userstamps create and update operations if the table has fields named created_by and/or updated_by.

Blame adds a userstamps migration helper which will create both created_by and updated_by columns in your table:

  create_table :widgets do |t|
    t.string :name
    t.timestamps
    t.userstamps
  end

Blame assumes that you are using restful-authentication and defaults to looking for the current user in User.current_user. You can override this behavior by writing your own userstamp_object method in ActiveRecord::Base or any of your models. For example:

  def userstamp_object
    User.find(session[:user_id])
  end

Automatic userstamping can be turned off globally by setting:

ActiveRecord::Base.record_userstamps = false

Installation

ruby script/plugin install git://github.com/infused/blame.git

Credit

Thanks to DeLynn Berry delynn@gmail.com for writing the original Userstamp plugin (http://github.com/delynn/userstamp/tree/master), which I've used in many project over the last several years. Unfortunately, its grown too complex and hard to keep up to date with Rails releases for my tastes. The Blame plugin attempts to mirror the simplicity of ActiveRecord's timestamp module.

Copyright (c) 2008 Keith Morrison keithm@infused.org, released under the MIT license