projectzebra / Redcrumbs

Fast and unobtrusive activity tracking of ActiveRecord models using DataMapper and Redis.
13 stars 0 forks source link

Does not show the true creator of the Crumb #6

Open jimishjoban opened 11 years ago

jimishjoban commented 11 years ago

Hey guys,

Great gem! Found this issue:

Lets say User A creates a new comment. User B (Moderator) edits this comment. Changes are recorded fine... But if we do

crumb = c.crumbs.last
crumb.creator

It would print User A as the crumb creator instead of User B...

JonMidhir commented 9 years ago

@jimishjoban I guess this is a little out of date now, sorry! :watch:

The creator is assigned using a method on the model you're tracking and uses the options you've set at initialization. This method can be easily overridden on a class by class basis. Something like this might suit you:

class Comment < ActiveRecord::Base
  def creator
    # Whatever you want to assign as the creator
    if new_record?
      super
    else
      editors.last
    end
  end
end