module TrackChanges module ActionController #:nodoc: def self.included(base) base.send :extend, ClassMethods end module ClassMethods # Sets up an around filter to assign the controller's current_user # to the given model names that are already set as instance variables in a # prior before_filter. # # Example: # # track_changes :post # track_changes :post, :post_attribute # # Currently does not work if the instance variable is anything except # an model that has current_user accessors. def track_changes models models_to_track = [models].flatten define_method(:__track_changes_to_models) { models_to_track } self.class_eval do helper :audits before_filter TrackChanges::CurrentUserFilter end end end end end