Keeping track of who did what

hello everybody.
i need to log “who did what” on some models. i was reading recipe 59
of rails recipes and i created something like that:

class LogSweeper < ActionController::Caching::Sweeper
observe :model1, :model2, :model3, :model4, :model5, …

save_log(model, “save”)

save_log(model, "destroy)

save_log(model, event, user_id = controller.session[:account_id])
#create the log entry, i want to save the id of the model, the id
of the logged user and something to describe the action.
#controller isn’t defined here so i can’t access the user_id.

in environment.rb i added:
config.active_record.observers = :log_sweeper

the sweeper is called when something happen to the observed models,
but i can’t access the controller (and so, the user_id) from there.
any help?

Why not use one of the versioning/auditing gems (http://ruby- instead?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs