X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/374d9ea486dcf6bb6ad2fe5bb4e5a180a8f556a3..9189093997610a8f289037d37b683c9fed060ae1:/app/models/segment.rb diff --git a/app/models/segment.rb b/app/models/segment.rb index ddfc3db03..774517e2c 100644 --- a/app/models/segment.rb +++ b/app/models/segment.rb @@ -4,11 +4,12 @@ class Segment < ActiveRecord::Base validates_numericality_of :node_a validates_numericality_of :node_b - # FIXME validate a nd b exist and are visible has_many :old_segments, :foreign_key => :id belongs_to :user + has_one :from_node, :class => 'Node', :foreign_key => 'node_a' + has_one :to_node, :class => 'Node', :foreign_key => 'node_b' def self.from_xml(xml, create=false) p = XML::Parser.new @@ -102,5 +103,8 @@ class Segment < ActiveRecord::Base end end + def precondtions_ok? + return from_node and from_node.visible and to_node and to_node.visible + end end