Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-872

Definition of persisted? does not conform to ActiveModel

    • Type: Icon: Task Task
    • Resolution: Done
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      In Mongoid, #persisted? returns false only for new documents:

      def persisted?
        !new_record?
      end
      

      But if Mongoid strives to adhere to the ActiveModel API (and it seems to), #persisted? should also return false for documents that have been destroyed. From the changelog of ActiveModel 3.0.0:

      > A model is persisted if it's not a new_record? and it was not destroyed?

      Which would be:

      def persisted?
        !new_record? && !destroyed?
      end
      

      I'm posting here instead of submitting a patch because I don't know Mongo well, so I wonder: is this a Mongo thing, or is it a bug?

            Assignee:
            Unassigned Unassigned
            Reporter:
            crx crx
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: