lib/mongoid/changeable.rb
# Get the previous attribute value that was changed
# before the document was saved.
#
# It the document has not been saved yet, or was just loaded from database,
# this method returns nil for all attributes.
#
# @param [ String ] attr The attribute name.
#
# @return [ Object | nil ] Attribute value before the document was saved,
#   or nil if the document has not been saved yet.
Get the previous attribute value that was changed
before the document was saved.

It the document has not been saved yet, or was just loaded from database,
this method returns nil for all attributes.
Get the previous attribute value that was changed before the document was saved . It the document has not been saved yet or was just loaded from database this method returns nil for all attributes .
def attribute_previously_was(attr)
      attr = database_field_name(attr)
      if previous_changes.key?(attr)
        previous_changes[attr].first
      else
        previous_attributes[attr]
      end
    end
def attribute_previously_was ( attr ) attr = database_field_name ( attr ) if previous_changes . key? ( attr ) previous_changes [ attr ] . first else previous_attributes [ attr ] end end
Get the previous attribute value that was changed
before the document was saved.
Get the previous attribute value that was changed before the document was saved .
Attribute value before the document was saved, or nil if the document has not been saved yet.
Attribute value before the document was saved or nil if the document has not been saved yet .
 Object | nil 
attr
<not_specific>
<not_specific>
attr The attribute name.
attr The attribute name .