Module: RecordHistory::Model::InstanceMethods
- Defined in:
- lib/record_history/has_record_history.rb
Instance Method Summary (collapse)
Instance Method Details
- (Object) build_record_history_obj
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/record_history/has_record_history.rb', line 40 def build_record_history_obj self.record_history_obj ||= [] self.class.new.attributes.keys.each do |attr_name| if (self.send("#{attr_name}_changed?")) next if self.class.record_history_only && !self.class.record_history_only.include?(attr_name) next if self.class.record_history_ignore && self.record_history_ignore.include?(attr_name) self.record_history_obj << RecordHistoryModel.new( :item_type => self.class.name, :item_id => self.id, :attr_name => attr_name, :old_value => self.send("#{attr_name}_was"), :new_value => self.send("#{attr_name}"), :author => RecordHistory. ) end end end |
- (Object) save_record_history_obj
58 59 60 |
# File 'lib/record_history/has_record_history.rb', line 58 def save_record_history_obj self.record_history_obj.each{|item| item.save} end |