Module: TrackChanges::ActionController
- Defined in:
- lib/track_changes/action_controller.rb
Instance Method Summary collapse
-
#track_changes(models, *args) ⇒ Object
Sets up an around filter to assign the controller’s
current_userto the given model names that are already set as instance variables in a priorbefore_filter.
Instance Method Details
#track_changes(models, *args) ⇒ Object
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.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/track_changes/action_controller.rb', line 15 def track_changes models, *args models_to_track = [] models_to_track << models if args.kind_of?(Array) models_to_track << args end models_to_track.flatten! define_method(:__track_changes_to_models) { models_to_track } self.class_eval do helper :audits before_filter TrackChanges::CurrentUserFilter end end |