From 40414cf324309d13d207f9339b7f40ce05a9fa2a Mon Sep 17 00:00:00 2001 From: Shaun McDonald Date: Tue, 30 Sep 2008 18:21:56 +0000 Subject: [PATCH] changing the belongs_to and has_many items in the models to reflect the new foriegn keys in the db and the fact that a (old)node/way/relation now belong to a changeset, which in turn has a user. --- app/models/changeset.rb | 7 +++++++ app/models/node.rb | 2 +- app/models/old_node.rb | 2 +- app/models/old_relation.rb | 2 +- app/models/old_way.rb | 2 +- app/models/relation.rb | 2 +- app/models/way.rb | 2 +- 7 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/models/changeset.rb b/app/models/changeset.rb index c9eeb0018..04023ae2b 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -4,6 +4,13 @@ class Changeset < ActiveRecord::Base belongs_to :user has_many :changeset_tags, :foreign_key => 'id' + + has_many :nodes + has_many :ways + has_many :relations + has_many :old_nodes + has_many :old_ways + has_many :old_relations def self.from_xml(xml, create=false) begin diff --git a/app/models/node.rb b/app/models/node.rb index 677023179..2efdb1bc9 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -10,7 +10,7 @@ class Node < ActiveRecord::Base validates_numericality_of :latitude, :longitude validate :validate_position - belongs_to :user + belongs_to :changeset has_many :old_nodes, :foreign_key => :id diff --git a/app/models/old_node.rb b/app/models/old_node.rb index 6b6b71b53..58a514bcd 100644 --- a/app/models/old_node.rb +++ b/app/models/old_node.rb @@ -8,7 +8,7 @@ class OldNode < ActiveRecord::Base validates_numericality_of :latitude, :longitude validate :validate_position - belongs_to :user + belongs_to :changeset def validate_position errors.add_to_base("Node is not in the world") unless in_world? diff --git a/app/models/old_relation.rb b/app/models/old_relation.rb index f5885f39f..9dca97a27 100644 --- a/app/models/old_relation.rb +++ b/app/models/old_relation.rb @@ -1,7 +1,7 @@ class OldRelation < ActiveRecord::Base set_table_name 'relations' - belongs_to :user + belongs_to :changeset def self.from_relation(relation) old_relation = OldRelation.new diff --git a/app/models/old_way.rb b/app/models/old_way.rb index 3c88c4673..2820d9438 100644 --- a/app/models/old_way.rb +++ b/app/models/old_way.rb @@ -1,7 +1,7 @@ class OldWay < ActiveRecord::Base set_table_name 'ways' - belongs_to :user + belongs_to :changeset def self.from_way(way) old_way = OldWay.new diff --git a/app/models/relation.rb b/app/models/relation.rb index e46da5ade..bb8f2d003 100644 --- a/app/models/relation.rb +++ b/app/models/relation.rb @@ -3,7 +3,7 @@ class Relation < ActiveRecord::Base set_table_name 'current_relations' - belongs_to :user + belongs_to :changeset has_many :old_relations, :foreign_key => 'id', :order => 'version' diff --git a/app/models/way.rb b/app/models/way.rb index 3bc8bcebe..8da959853 100644 --- a/app/models/way.rb +++ b/app/models/way.rb @@ -3,7 +3,7 @@ class Way < ActiveRecord::Base set_table_name 'current_ways' - belongs_to :user + belongs_to :changeset has_many :old_ways, :foreign_key => 'id', :order => 'version' -- 2.39.5