lib/acts_as_audited_rails3/base.rb
def write_audit(attrs)
          self.audit_comment = nil

          if auditing_full_model_enabled
            # Grab all the object attributes and dump them into a Map, then turn the map into YAML and store in the Audit table
            self.class.reflect_on_all_associations.each {|assn| self.send assn.name.to_sym} # Load up all associations to store in the full_model serialization
            ignore_properties = if non_audited_columns
              non_audited_columns.map {|prop| "@#{prop.to_s}"}
            else
              []
            end
            props = (self.to_yaml_properties.map{|y| y.strip} - ignore_properties)
            attributes_map = props.inject({}) do |acc, name| 
              name = name.gsub /@/, ''
              
              begin
                if self.respond_to? name.to_sym
                  val = self.send name.to_sym
                  unless val.blank? || (val.is_a?(Array) && val.empty?)
                    acc[name.to_sym] = val 
                  end
                end
              rescue Exception => exception 
                error_msg = "Error serializing property #{name}; got exception #{exception.to_s} with backtrace #{exception.backtrace.inspect}"
                p error_msg
                logger.error error_msg
              end
              acc
            end
            attributes_map[:attributes] = self.attributes.except(*non_audited_columns)
            
            attrs[:full_model] = attributes_map.to_yaml
          end
          
          self.audits.create attrs if auditing_enabled
        end
# Note- with to_yaml it's easy to get into some sort of recursion issues.  If you see something like:
#    yaml TypeError: wrong argument type nil (expected Data)
# check to see what other model objects are being pulled in; you may want to limit them.  For example, the RequestProgram was pulling in 
# request as an attribute.  This caused issues.  I solved this by adding not pulling in request_programs into YAML via the to_yaml_properties_with_specific method.
# In general, you want to stay away from linking objects like RequestProgram and instead use one that list programs.
Note- with to_yaml it's easy to get into some sort of recursion issues.  If you see something like:
yaml TypeError: wrong argument type nil (expected Data)
check to see what other model objects are being pulled in; you may want to limit them.  For example, the RequestProgram was pulling in
request as an attribute.  This caused issues.  I solved this by adding not pulling in request_programs into YAML via the to_yaml_properties_with_specific method.
In general, you want to stay away from linking objects like RequestProgram and instead use one that list programs.
Note - with to_yaml it ' s easy to get into some sort of recursion issues . If you see something like : yaml TypeError : wrong argument type nil ( expected Data ) check to see what other model objects are being pulled in ; you may want to limit them . For example the RequestProgram was pulling in request as an attribute . This caused issues . I solved this by adding not pulling in request_programs into YAML via the to_yaml_properties_with_specific method . In general you want to stay away from linking objects like RequestProgram and instead use one that list programs .
def write_audit(attrs)
          self.audit_comment = nil
          if auditing_full_model_enabled
            self.class.reflect_on_all_associations.each {|assn| self.send assn.name.to_sym} 
            ignore_properties = if non_audited_columns
              non_audited_columns.map {|prop| "@#{prop.to_s}"}
            else
              []
            end
            props = (self.to_yaml_properties.map{|y| y.strip} - ignore_properties)
            attributes_map = props.inject({}) do |acc, name| 
              name = name.gsub /@/, ''
              begin
                if self.respond_to? name.to_sym
                  val = self.send name.to_sym
                  unless val.blank? || (val.is_a?(Array) && val.empty?)
                    acc[name.to_sym] = val 
                  end
                end
              rescue Exception => exception 
                error_msg = "Error serializing property #{name}; got exception #{exception.to_s} with backtrace #{exception.backtrace.inspect}"
                p error_msg
                logger.error error_msg
              end
              acc
            end
            attributes_map[:attributes] = self.attributes.except(*non_audited_columns)
            attrs[:full_model] = attributes_map.to_yaml
          end
          self.audits.create attrs if auditing_enabled
        end
def write_audit ( attrs ) self . audit_comment = nil if auditing_full_model_enabled self . class . reflect_on_all_associations . each { | assn | self . send assn . name . to_sym } ignore_properties = if non_audited_columns non_audited_columns . map { | prop | "@#{prop.to_s}" } else [ ] end props = ( self . to_yaml_properties . map { | y | y . strip } - ignore_properties ) attributes_map = props . inject ( { } ) do | acc , name | name = name . gsub / @ / , '' begin if self . respond_to? name . to_sym val = self . send name . to_sym unless val . blank? || ( val . is_a? ( Array ) && val . empty? ) acc [ name . to_sym ] = val end end rescue Exception => exception error_msg = "Error serializing property #{name}; got exception #{exception.to_s} with backtrace #{exception.backtrace.inspect}" p error_msg logger . error error_msg end acc end attributes_map [ :attributes ] = self . attributes . except ( * non_audited_columns ) attrs [ :full_model ] = attributes_map . to_yaml end self . audits . create attrs if auditing_enabled end
Note- with to_yaml it's easy to get into some sort of recursion issues.
Note - with to_yaml it ' s easy to get into some sort of recursion issues .
# Grab all the object attributes and dump them into a Map, then turn the map into YAML and store in the Audit table # Load up all associations to store in the full_model serialization
attrs