So basically I need to return the value of the previous Point.
e.g. I’m on the third point. I need the point.kilometric_position of the second point.
Part of my controller action is pasted here. Thanks in advance!
def calculate
@points = Point.all
# loop through all the points
@points.each do |point|
# calculate the current kilometric position
if point.kilometric_position.nil?
# kilometric_position = previous_kilometric_position + distance
end
end
end
1 Answer