has_one关系在当前对象中添加另一个对象

问题描述 投票:0回答:1

我有一个具有punch_to:user关系的模型打孔器,但是当我调用打孔对象时,我正在将用户对象与打孔对象结合在一起,如何在调用打孔对象时从打孔对象中删除用户对象?

2.5.1 :001 > Punch.last
 => #<Punch _id: 5dc28149d807465afb0750b2, created_at: 2019-11-06 08:16:09 UTC, updated_at: 2019-11-06 08:16:09 UTC, deleted_at(deleted_at): nil, punch_in_datetime: 2019-11-06 08:16:06 UTC, punch_in_latitude: 17.7262481, punch_in_longitude: 83.3065046, punch_in_timezone: "+05:30", punch_out_datetime: nil, punch_out_latitude: nil, punch_out_longitude: nil, punch_out_timezone: nil, time_in: true, punch_id: "57d09dc3-367a-435b-9c3c-9b5bf8a29cdb", late_timeout_reason_id: nil, distance_travelled: 0.0, duration: nil, _keywords: ["367a", "435b", "57d09dc3", "9b5bf8a29cdb", "9c3c", "aravind", "com", "gmail", "nikhil"], user_id: BSON::ObjectId('5dbff700d807466d0660fba2')> 
ruby-on-rails mongoid
1个回答
1
投票
[Punch模型belongs_to User,这意味着Punch对象将具有user_id,在您的Punch对象示例中,我只能看到user_id,这是正确的。
© www.soinside.com 2019 - 2024. All rights reserved.