-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Affects Version/s: 8.1.5
-
Component/s: Associations
-
None
-
Ruby Drivers
If you use `.only` when fetching a model that embeds other models, then use the relation metadata to try to traverse back up from the embedded models, you get a missing attribute error
This issue is not present in v6 or v7
class Car include Mongoid::Document embeds_one :steering_wheel end class SteeringWheel include Mongoid::Document embedded_in :car end Car.collection.drop id = BSON::ObjectId.new Car.collection.insert_one "_id" => id, "steering_wheel" => \{ "_id" => BSON::ObjectId.new } car = Car.where(id: id).only("_id", "steering_wheel._id").first # 7.5 - works # 8.1 - raises ActiveModel::MissingAttributeError pp car.steering_wheel.car