Module: ActiveRecordExtensions::InstanceMethods
- Defined in:
- lib/rails_core_extensions/active_record_extensions.rb
Instance Method Summary collapse
- #all_errors ⇒ Object
-
#audit_log ⇒ Object
getting audits.
- #to_drop ⇒ Object (also: #to_liquid)
-
#unique_id ⇒ Object
A unique id - even if you are unsaved!.
Instance Method Details
#all_errors ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rails_core_extensions/active_record_extensions.rb', line 59 def all_errors errors_hash = {} self.errors.each do |attr, msg| (errors_hash[attr] ||= []) << if self.respond_to?(attr) && (record_attr = self.send(attr)).is_a?(ActiveRecord::Base) record_attr.all_errors else msg end end errors_hash end |
#audit_log ⇒ Object
getting audits
83 84 85 |
# File 'lib/rails_core_extensions/active_record_extensions.rb', line 83 def audit_log return (self.methods.include?('audits') ? self.audits : []) end |
#to_drop ⇒ Object Also known as: to_liquid
71 72 73 74 |
# File 'lib/rails_core_extensions/active_record_extensions.rb', line 71 def to_drop @drop_class ||= (self.class.name+'Drop').constantize @drop_class.new(self) end |
#unique_id ⇒ Object
A unique id - even if you are unsaved!
78 79 80 |
# File 'lib/rails_core_extensions/active_record_extensions.rb', line 78 def unique_id id || @generated_dom_id || (@generated_dom_id = Time.now.to_f.to_s.gsub('.', '_')) end |