public
Description: Blame is a simple alternative to the userstamp plugin for Rails, which adds userstamps to ActiveRecord models
Homepage:
Clone URL: git://github.com/infused/blame.git
blame /
name age message
file CHANGELOG.rdoc Sun Jan 04 21:14:27 -0800 2009 Update version to 1.1.1 [infused]
file MIT-LICENSE Sun Jan 04 21:14:27 -0800 2009 Update version to 1.1.1 [infused]
file README.rdoc Sun Jan 04 21:14:27 -0800 2009 Update version to 1.1.1 [infused]
file Rakefile Wed Oct 08 15:02:33 -0700 2008 Giving birth to a new plugin [infused]
file about.yml Sun Jan 04 21:14:27 -0800 2009 Update version to 1.1.1 [infused]
file init.rb Wed Oct 08 15:02:33 -0700 2008 Giving birth to a new plugin [infused]
directory lib/ Sun Jan 04 21:11:24 -0800 2009 The migration helper now supports custom column... [infused]
directory test/ Thu Dec 04 16:57:18 -0800 2008 Refactor tests [infused]
README.rdoc

Blame

Automatically userstamps create and update operations if the table has columns named created_by and/or updated_by. The Blame plugin attempts to mirror the simplicity of ActiveRecord’s timestamp module.

Blame assumes that you are using restful-authentication and expects User.current_user to return the 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

If you don’t like created_by/updated_by you can customize the column names:

  # Globally in environment.rb
  ActiveRecord::Base.created_userstamp_column = :creator_id

  # In a model definition
  class Subscription
    self.created_userstamp_column = :creator_id
    self.updated_userstamp_column = :updater_id
  end

Automatic userstamping can be turned off globally by setting:

  ActiveRecord::Base.record_userstamps = false

Blame adds a userstamps migration helper which will add the created_by and updated_by columns (or your custom column names) to your table:

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

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 (github.com/delynn/userstamp/tree/master), which is the inspiration for this plugin.

Copyright © 2008-2009 Keith Morrison <keithm@infused.org>, released under the MIT license