On 2006-08-01, at 12:18 , David wrote:
That’s great, thank you. I guess I can use that in the application
controller then filter out only the actions I am interested in saving
Yea, I intended it to be in the application controller.
Should I add the after_filter to the application controller and then
observe it from the cache sweeper, or just add both to the controller?
You don’t need to observe anything, do you?
I think you can handle it all from the controller.
I messed up in my previous suggestion, for a while I thought you
asked about something else: I’d use that observer/filter pattern to
set a user_id field whenever a record is saved.
Do you have any advice on how to manage the mapping of which actions I
wish to save audit information about? A hash of their names perhaps?
A hash is fine. You can go fancy with a DSL class method, so:
def self.audit_actions *actions
write_inheritable_array :audit_actions, [actions].flatten.compact
class SecurityController < …
audit_actions :login, :logout, :change_password
And my log_action, modified:
return unless read_inheritable_attribute(
:controller => controller_path,
:action => action_name)