- has_many :containing_relations, :class_name => "Relation", :through => :containing_relation_members, :source => :relation, :extend => ObjectFinder
-
- def validate_position
- errors.add_to_base("Node is not in the world") unless in_world?
- end
+ has_many :containing_relations, :class_name => "Relation", :through => :containing_relation_members, :source => :relation
+
+ validates :id, :uniqueness => true, :presence => { :on => :update },
+ :numericality => { :on => :update, :only_integer => true }
+ validates :version, :presence => true,
+ :numericality => { :only_integer => true }
+ validates :latitude, :presence => true,
+ :numericality => { :only_integer => true }
+ validates :longitude, :presence => true,
+ :numericality => { :only_integer => true }
+ validates :timestamp, :presence => true
+ validates :changeset, :associated => true
+ validates :visible, :inclusion => [true, false]
+
+ validate :validate_position
+
+ scope :visible, -> { where(:visible => true) }
+ scope :invisible, -> { where(:visible => false) }