Sha256: c84974e7bf6f62e43a1bb62f1d6e686cdee8e477063b43d0f804a0336525821e

Contents?: true

Size: 528 Bytes

Versions: 4

Compression:

Stored size: 528 Bytes

Contents

# Configures a resource_controller to automatically set a user performing a record change.
# origin: RM
module BoringControllerTrait::LogChangesTrait
  as_trait do

    [:object, :build_object].each do |method|
      define_method method do |*args|
        super.tap do |record|
          if record.present? && record.respond_to?(:changing_user=)
            record.changing_user = current_user
            # the actual logging takes place in the object model after saving
          end
        end
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
serum-rails-0.2.1 spec/test_apps/rails-2-3/app/controllers/shared/boring_controller_trait/log_changes_trait.rb
serum-rails-0.2.0 spec/test_apps/rails-2-3/app/controllers/shared/boring_controller_trait/log_changes_trait.rb
serum-rails-0.1.1 spec/test_app/app/controllers/shared/boring_controller_trait/log_changes_trait.rb
serum-rails-0.1.0 spec/test_app/app/controllers/shared/boring_controller_trait/log_changes_trait.rb