我正在使用 GPS 记录轨迹并将其发送到我的 Postgre DB,然后我想删除速度 = 0 的前导和尾随测量值。我这样尝试:
while track.measurements.last.speed == 0
track.measurements.last.destroy
end
(track.measurements.first 相同)。当这段代码被执行时,一切都会停止而没有任何错误。我通过调试和一步步去发现的是,它在这两行之间反复切换:
(rdb:102) s /var/lib/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/associations.rb:156 关联=关联实例获取(名称)
(rdb:102) l
[151, 160] in /var/lib/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/associations.rb
151 # :nodoc:
152 attr_reader :association_cache
153
154 # Returns the association instance for the given name, instantiating it if it doesn't already exist
155 def association(name) #:nodoc:
=> 156 association = association_instance_get(name)
157
158 if association.nil?
159 reflection = self.class.reflect_on_association(name)
160 association = reflection.association_class.new(self, reflection)
(rdb:102) s
/var/lib/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/associations.rb:170
@association_cache[name.to_sym]
(rdb:102) l
[165, 174] in /var/lib/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/associations.rb
165 end
166
167 private
168 # Returns the specified association instance if it responds to :loaded?, nil otherwise.
169 def association_instance_get(name)
=> 170 @association_cache[name.to_sym]
171 end
172
173 # Set the specified association instance.
174 def association_instance_set(name, association)
可悲的是,这对我来说毫无意义。有人可以在这里帮忙吗?