直接ロードされたオブジェクトとは異なるオブジェクトを参照する条件との関連付けがあります。
it "should point to the same object" do
user = create(:user)
user.current_location.should == nil
user.update_location(latitude: 11, longitude: 22)
user.current_location.should_not == nil
location = UserLocation.first
location.id.should == user.current_location.id
location.object_id.should == user.current_location.object_id #fails on this line
end
私の考えでは、関連付けと直接ロードされたオブジェクトの両方が同じオブジェクトを指している必要があります。これは予想される動作ですか?
これが私のモデルの重要な部分の要点です: https ://gist.github.com/2635673