-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
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>]