Module: SimpleDrilldown::Changes::ClassMethods
- Defined in:
- lib/simple_drilldown/changes.rb
Overview
Class methods for Changes
Instance Method Summary collapse
Instance Method Details
#changes_for(*fields) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/simple_drilldown/changes.rb', line 12 def changes_for(*fields) fields.each do |field| condition_proc = lambda do in_join = is_a?(ActiveRecord::Associations::JoinDependency::JoinAssociation) table_alias = in_join ? aliased_table_name : AuditLog.table_name "#{table_alias}.new_values LIKE '%#{field}%'" end has_many :"#{field}_changes", -> { where(condition_proc.call).order(:created_at) }, class_name: :AuditLog, foreign_key: :record_id end end |