Rails Port and API 0.6

I installed Rails Port following exactly manual on http://wiki.openstreetmap.org/wiki/The_Rails_Port on my local virtual machine. Everything is fine, when I access page, it shows main page. But i did it, because I need to access OpenStreetMap API functions. When I access, I got reply

and thats great… But when I try to load bounding box,50.073,14.423,50.079

I got 500 with message NoMethodError: undefined method `visible?’ for nil:NilClass

When I look into Rails log

[2010-04-20 10:41:41.610691 #9646] Node Load (1.5ms) SELECT * FROM “current_nodes” WHERE (“current_nodes”.“id” = 24568519)
[2010-04-20 10:41:41.615082 #9646] Node Load (1.2ms) SELECT * FROM “current_nodes” WHERE (“current_nodes”.“id” = 24568552)
[2010-04-20 10:41:41.616761 #9646] API threw unexpected NoMethodError exception: undefined method visible?' for nil:NilClass [2010-04-20 10:41:41.616973 #9646] /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/whiny_nil.rb:52:in method_missing’

I tried to access it with JOSM, where I set OSM server address to but it returns the same.

I imported data into database by Osmosis 1.34 but I am not sure, if it was correct because when I called

bin/osmosis --read-xml file=“…/KN.osm” --write-apidb host=“localhost:5432” database=“openstreetmap” user=“openstreetmap” password=“osm”

it failed on

SEVERE: Thread for task 1-read-xml failed
org.openstreetmap.osmosis.core.OsmosisRuntimeException: Database version mismatc h. The schema contains unexpected migrations [43, 42, 41, 40, 49, 48, 45, 44, 47 , 46], may need to upgrade osmosis or specify validateSchemaVersion=no.

so I specified validateSchemaVersion=“no” and it seems it worked… There are many rows in all tables.

When I run tests (sudo rake test) it returned 4 failures but according manual, there should be only 3 failures.

  1. Failure:
    test_changes_simple(ApiControllerTest) [/test/functional/api_controller_test.rb: 204]:
    Expected response to be a <:success>, but was <500>

  2. Failure:
    [/test/functional/api_controller_test.rb:228:in `test_changes_zoom_valid’
    /test/functional/api_controller_test.rb:226:in `upto’
    /test/functional/api_controller_test.rb:226:in `test_changes_zoom_valid’]:
    Expected response to be a <:success>, but was <500>

  3. Failure:
    [/test/functional/api_controller_test.rb:257:in `test_hours_valid’
    /test/functional/api_controller_test.rb:255:in `upto’
    /test/functional/api_controller_test.rb:255:in `test_hours_valid’]:
    Expected response to be a <:success>, but was <500>

  4. Failure:
    test_delete(NodeControllerTest) [/test/functional/node_controller_test.rb:224]:
    <“Precondition failed: Node 3 is still used by way 1.”> expected but was
    <“Precondition failed: Node 3 is still used by way 3.”>.

Do you have any idea how to fix error
“NoMethodError: undefined method `visible?’ for nil:NilClass”

Thanks in advance

May be I understand… The error is like null pointer exception and when I was running the query before it failed (SELECT * FROM “current_ways” WHERE (“current_ways”.“id” = 4097030), it returns no result… So i was changing bbox to smaller and finally it returned required XML. Probably the only one solution is to import bigger part of map and to hope, that there won’t be way crossing my borders. Or may I do something diffirent(like set settings when it find no result, it won’t add the way…)?


Looks like this error appears when you partially imported osm data into the database. I got it while importing only coastlines from a planet dump with osmosis (–way-key-value keyValueList=“natural.coastline” --used-node).

The solution is to fix this line in ruby code:

--- a/app/models/relation.rb
+++ b/app/models/relation.rb
@@ -126,7 +126,7 @@ class Relation < ActiveRecord::Base
         # otherwise, manually go to the db to check things
-        if member.member.visible?
+        if member.member and member.member.visible?