Skip to content

wink/blame

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 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

You can change the names of the userstamp columns:

# 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
ruby script/plugin install git://github.com/infused/blame.git

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 Keith Morrison <keithm@infused.org>, released under the MIT license

About

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

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors