+ self.table_name = "nodes"
+ self.primary_keys = "node_id", "version"
+
+ # note this needs to be included after the table name changes, or
+ # the queries generated by Redactable will use the wrong table name.
+ include Redactable
+
+ validates_presence_of :changeset_id, :timestamp
+ validates_inclusion_of :visible, :in => [true, false]
+ validates_numericality_of :latitude, :longitude
+ validate :validate_position
+ validates_associated :changeset
+
+ belongs_to :changeset
+ belongs_to :redaction
+ belongs_to :current_node, :class_name => "Node", :foreign_key => "node_id"
+
+ has_many :old_tags, :class_name => "OldNodeTag", :foreign_key => [:node_id, :version]
+
+ def validate_position
+ errors.add(:base, "Node is not in the world") unless in_world?
+ end