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

Associations reload flag non-functioning

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

      It appears the reload flag for associations is not functioning properly. Here is a simple use case:

      class Person
      include Mongoid::Document
      has_many :questions
      has_and_belongs_to_many :followings, :class_name => 'Question', :inverse_of => :followers
      end

      class Question
      include Mongoid::Document
      belongs_to :user
      has_and_belongs_to_many :followers, :class_name => 'Person', :inverse_of => :followings
      end

      > q = Question.create
      > p = Person.create
      > q.followers << Person.last
      > q.followers
      => [#<Person _id: 4d3cc291f42ce1bfc4000006, following_ids: [BSON::ObjectId('4d3cc290f42ce1bfc4000005')]>]
      > p.followings
      => []
      > p.followings(true)
      => []
      > p.reload.followings
      => [#<Question _id: 4d3cc290f42ce1bfc4000005, follower_ids: [BSON::ObjectId('4d3cc291f42ce1bfc4000006')], user_id: nil>]

            Assignee:
            durran Durran Jordan
            Reporter:
            KieranP Kieran Pilkington [X]
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: