]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/relation.rb
Use a local lookup table for country bounding boxes rather than relying
[rails.git] / app / models / relation.rb
index b66d957b90ae3bdb5827accab6a9ed28f2642f40..24b139f0ddd33dbe34ebe85634fabf0904bc48b5 100644 (file)
@@ -218,6 +218,11 @@ class Relation < ActiveRecord::Base
     # in the hash to be overwritten.
     raise OSM::APIDuplicateTagsError.new("relation", self.id, k) if @tags.include? k
 
+    # check tag size here, as we don't create a RelationTag object until
+    # just before we save...
+    raise OSM::APIBadUserInput.new("Relation #{self.id} has a tag with too long a key, '#{k}'.") if k.length > 255
+    raise OSM::APIBadUserInput.new("Relation #{self.id} has a tag with too long a value, '#{k}'='#{v}'.") if v.length > 255
+
     @tags[k] = v
   end
 
@@ -298,7 +303,7 @@ class Relation < ActiveRecord::Base
         # use reflection to look up the appropriate class
         model = Kernel.const_get(m[0].capitalize)
         # get the element with that ID
-        element = model.find(m[1])
+        element = model.find(:first, :conditions =>["id = ?", m[1]])
 
         # and check that it is OK to use.
         unless element and element.visible? and element.preconditions_ok?