NoMethodError bei einfachem Beispiel

9 views
Skip to first unread message

morgler

unread,
Nov 10, 2008, 8:56:36 AM11/10/08
to ruby-opengeodb
Ich habe die OpenGeoDB und das ruby-opengeodb gem installiert. Danach
wollte ich das folgende Beispiel von der Homepage ausprobieren:

require 'rubygems'
require 'ruby-opengeodb'

class SandboxController < ApplicationController
def index
Location.db_connect
plzs = %w(13359 67059 90459 56068 69115)
@locations = []
plzs.each do |plz|
loc = Location.new(plz)
# @locations << loc
# puts "PLZ: #{plz} Ort: #{loc.ort} Lat: #{loc.lat} Lon:
#{loc.lon}"
end
end
end

Leider bekomme ich beim Aufruf von "Locations.new(plz)" folgende
Fehlermeldung:

You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]

I:/instant_rails_20/ruby/lib/ruby/gems/1.8/gems/ruby-opengeodb-0.1.0/
lib/ruby-opengeodb/location.rb:199:in `get_lat_lon'
I:/instant_rails_20/ruby/lib/ruby/gems/1.8/gems/ruby-opengeodb-0.1.0/
lib/ruby-opengeodb/location.rb:80:in `initialize'
app/controllers/sandbox_controller.rb:10:in `new'

Der Fehler scheint im Gem aufzutreten oder mache ich was falsch? Woher
kommt die Fehlermeldung? Die OpenGeoDB scheint korrekt eingerichtet
und wird ja auch problemlos geöffnet.

Ich bin für jede Hilfe dankbar!

Matthias
Reply all
Reply to author
Forward
0 new messages