Sha256: faca0b1df4ace10677e54c1e40a68611cec923dff5d3fa2634566e8f3ef26a62
Contents?: true
Size: 970 Bytes
Versions: 2
Compression:
Stored size: 970 Bytes
Contents
module TrackChanges module ActionController # Sets up an around filter to assign the controller's <tt>current_user</tt> # to the given model names that are already set as instance variables in a # prior <tt>before_filter</tt>. # # Example: # # track_changes :post # track_changes :post, :post_attribute # # Currently does not work if the instance variable is anything except # an model that has <tt>current_user</tt> accessors. 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 end end ActionController::Base.extend TrackChanges::ActionController
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
track_changes-1.0.1 | lib/track_changes/action_controller.rb |
track_changes-1.0.0 | lib/track_changes/action_controller.rb |