]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/relation.rb
Get rails to do asset tagging for the SWF file.
[rails.git] / app / models / relation.rb
index 5d7092908baa302c868cf8725378fb7d43763355..c8516b58a3441c9f3b0ec38262d7628c8888d00f 100644 (file)
@@ -106,20 +106,32 @@ class Relation < ActiveRecord::Base
   end 
 
   def self.find_for_nodes(ids, options = {})
   end 
 
   def self.find_for_nodes(ids, options = {})
-    self.with_scope(:find => { :joins => "INNER JOIN current_relation_members ON current_relation_members.id = current_relations.id", :conditions => "current_relation_members.member_type = 'node' AND current_relation_members.member_id IN (#{ids.join(',')})" }) do
-      return self.find(:all, options)
+    if ids.empty?
+      return []
+    else
+      self.with_scope(:find => { :joins => "INNER JOIN current_relation_members ON current_relation_members.id = current_relations.id", :conditions => "current_relation_members.member_type = 'node' AND current_relation_members.member_id IN (#{ids.join(',')})" }) do
+        return self.find(:all, options)
+      end
     end
   end
 
   def self.find_for_ways(ids, options = {})
     end
   end
 
   def self.find_for_ways(ids, options = {})
-    self.with_scope(:find => { :joins => "INNER JOIN current_relation_members ON current_relation_members.id = current_relations.id", :conditions => "current_relation_members.member_type = 'way' AND current_relation_members.member_id IN (#{ids.join(',')})" }) do
-      return self.find(:all, options)
+    if ids.empty?
+      return []
+    else
+      self.with_scope(:find => { :joins => "INNER JOIN current_relation_members ON current_relation_members.id = current_relations.id", :conditions => "current_relation_members.member_type = 'way' AND current_relation_members.member_id IN (#{ids.join(',')})" }) do
+        return self.find(:all, options)
+      end
     end
   end
 
   def self.find_for_relations(ids, options = {})
     end
   end
 
   def self.find_for_relations(ids, options = {})
-    self.with_scope(:find => { :joins => "INNER JOIN current_relation_members ON current_relation_members.id = current_relations.id", :conditions => "current_relation_members.member_type = 'relation' AND current_relation_members.member_id IN (#{ids.join(',')})" }) do
-      return self.find(:all, options)
+    if ids.empty?
+      return []
+    else
+      self.with_scope(:find => { :joins => "INNER JOIN current_relation_members ON current_relation_members.id = current_relations.id", :conditions => "current_relation_members.member_type = 'relation' AND current_relation_members.member_id IN (#{ids.join(',')})" }) do
+        return self.find(:all, options)
+      end
     end
   end
 
     end
   end