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

Update the updated_at field when updating a HABTM association

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Persistence

      Consider the following mongoid model:

       

      class Location  
        include Mongoid::Document  
        include Mongoid::Timestamps
      
        has_and_belongs_to_many :tags, class_name: 'LocationTag', inverse_of: nil
      end

      If we do:

      location.update(tags: LocationTag.all.to_a)
      

      the updated_at field of the location doesn't get bumped.

      However, if we do:

      location.update(tag_ids: LocationTag.all.map(&:id))

      It does bump the updated_at.

            Assignee:
            Unassigned Unassigned
            Reporter:
            martin.mochetti@gmail.com Martin Mochetti
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: