From: Nick Black Date: Mon, 12 Mar 2007 15:49:11 +0000 (+0000) Subject: Fixed precondition typo and segment_controller foreign key X-Git-Tag: live~8550 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/f75401ae29689d8081c2f047980a68be534ae436 Fixed precondition typo and segment_controller foreign key --- diff --git a/app/controllers/segment_controller.rb b/app/controllers/segment_controller.rb index 5f2603f0b..58e98bef2 100644 --- a/app/controllers/segment_controller.rb +++ b/app/controllers/segment_controller.rb @@ -16,7 +16,7 @@ class SegmentController < ApplicationController segment.from_node = Node.find(segment.node_a.to_i) segment.to_node = Node.find(segment.node_b.to_i) - unless segment.precondtions_ok? # are the nodes visible? + unless segment.preconditions_ok? # are the nodes visible? render :nothing => true, :status => 412 end diff --git a/app/controllers/way_controller.rb b/app/controllers/way_controller.rb index ec8f31003..fcff0fc45 100644 --- a/app/controllers/way_controller.rb +++ b/app/controllers/way_controller.rb @@ -10,7 +10,7 @@ class WayController < ApplicationController if way way.user_id = @user.id - unless way.precondtions_ok? # are the segments (and their nodes) visible? + unless way.preconditions_ok? # are the segments (and their nodes) visible? render :nothing => true, :status => 412 return end diff --git a/app/models/segment.rb b/app/models/segment.rb index a88bc9a5b..785701c3d 100644 --- a/app/models/segment.rb +++ b/app/models/segment.rb @@ -8,8 +8,8 @@ class Segment < ActiveRecord::Base has_many :old_segments, :foreign_key => :id belongs_to :user - has_one :from_node, :class_name => 'Node', :foreign_key => 'node_a' - has_one :to_node, :class_name => 'Node', :foreign_key => 'node_b' + has_one :from_node, :class_name => 'Node', :foreign_key => 'id' + has_one :to_node, :class_name => 'Node', :foreign_key => 'id' def self.from_xml(xml, create=false) p = XML::Parser.new @@ -103,7 +103,7 @@ class Segment < ActiveRecord::Base end end - def precondtions_ok? + def preconditions_ok? from_node and from_node.visible and to_node and to_node.visible end