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

Touch and models without timestamps

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 3.1.0
    • Component/s: None
    • Labels:
      None

      Description

      Hi,

      I have the following issue with mongoid 3.0.17:

      class Book
        include Mongoid::Document
        attr_accessible :title
        field :title
      end
       
      book = Book.create title: 'Cloud Atlas'
      book.respond_to? :touch
      book.touch
      book.reload
      book.title
      

      book responds to touch and book.touch returns true, but after reloading its

       is 

      nil

      
      

      ruby
      class BookWithTimestamps
      include Mongoid::Document
      include Mongoid::Timestamps
      attr_accessible :title
      field :title
      end

      book_with_timestamps = BookWithTimestamps.create title: 'Cloud Atlas'
      book_with_timestamps.respond_to? :touch
      book_with_timestamps.touch
      book_with_timestamps.reload
      book_with_timestamps.title
      `

      Everything is fine when the model has timestamps.

      I don't know if it's a bug or not, but I found this strange behaviour and reported it.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: