No commit activity in last 3 years
No release in over 3 years
Automatically set created_by and updated_by fields
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 3.0.0
>= 2.0.0
>= 1.3.1
 Project Readme

Description¶ ↑

The acts_as_blamable plugin stores the creator and updater of an ActiveRecord model.

Installation¶ ↑

gem install acts_as_blamable

Usage¶ ↑

Add a current_user class method to the User model, which returns for example the logged in user.

class User < ActiveRecord::Base
  def self.current_user
    ...
  end
end

class Post < ActiveRecord::Base
 acts_as_blamable
end

Add created_by and updated_by attributes to the posts table.

create_table :posts do |t|
  t.integer :created_by, :updated_by
end

Configuration¶ ↑

Defaults

{ :current_user_method => 'current_user', :class_name => 'User', :creator_foreign_key => :created_by, :updater_foreign_key => :updated_by }

Modify the defaults if necessary

class Person < ActiveRecord::Base
  def self.current_person
    Person.first
  end
end

class Comment < ActiveRecord::Base
  acts_as_blamable :class_name => 'Person', :creator_foreign_key => :creator_id, :updater_foreign_key => :updater_id, :current_user_method => 'current_person'
end

Specs¶ ↑

Tested with Ruby on Rails version: 3.0.0 and ruby version Ruby Enterprise Edition 1.8.7 build 2010.02.