]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/way_tag.rb
Fix bug allowing created elements to reference deleted ones
[rails.git] / app / models / way_tag.rb
index fa9b4336177061287d00d4b153a9da6cef28c6a9..99d435d33a7d78dec9e00af3f38d263d57b2cfc5 100644 (file)
@@ -1,14 +1,10 @@
 class WayTag < ActiveRecord::Base
-  set_table_name 'current_way_tags'
+  self.table_name = "current_way_tags"
+  self.primary_keys = "way_id", "k"
 
-  # False multipart keys. The following would be a hack:
-  # set_primary_keys :id, :k, :v
-  # FIXME add a real multipart key to waytags so that we can do eager loadin
+  belongs_to :way
 
-  belongs_to :way, :foreign_key => 'id'
-  
-  validates_presence_of :id
-  validates_length_of :k, :v, :maximum => 255, :allow_blank => true
-  validates_uniqueness_of :id, :scope => :k
-  validates_numericality_of :id, :only_integer => true
+  validates :way, :presence => true, :associated => true
+  validates :k, :v, :allow_blank => true, :length => { :maximum => 255 }
+  validates :k, :uniqueness => { :scope => :way_id }
 end