Sha256: 6b9c78be9d2894e292f1027250300efee9e1554506d6ee8490fe65d4394c1934
Contents?: true
Size: 769 Bytes
Versions: 1
Compression:
Stored size: 769 Bytes
Contents
module Logga module ActiveRecord extend ActiveSupport::Concern class_methods do def add_log_entries_for_updates! around_update :log_model_changes end end def log_model_changes field_changes = changes log_field_changes(field_changes) if yield end def log_field_changes(changes) changes.each { |field, values| log_field_change(field, *values) } end def log_field_change(field, old_value, new_value) author_data = Hash(try(:author)) self.log_entries.create( body: "changed #{field} from #{old_value} to #{new_value}", author_id: author_data[:id], author_tupe: author_data[:type], author_name: author_data[:name] ) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
logga-0.1.0 | lib/logga/active_record.rb |