Handle segments which do not exist correctly and indicate that the
[rails.git] / app / models / way.rb
index c6316d330809992df17afad252f77922445ab4b3..09d1dafa0adca5b320aaad2003b63c36b9d85e43 100644 (file)
@@ -165,7 +165,7 @@ class Way < ActiveRecord::Base
 
         WaySegment.delete_all(['id = ?', self.id])
 
-        i = 0
+        i = 1
         segs.each do |n|
           seg = WaySegment.new
           seg.id = self.id
@@ -189,7 +189,7 @@ class Way < ActiveRecord::Base
   def preconditions_ok?
     return false if self.segs.empty?
     self.segs.each do |n|
-      segment = Segment.find(n)
+      segment = Segment.find(:first, :conditions => ["id = ?", n])
       unless segment and segment.visible and segment.preconditions_ok?
         return false
       end