I got undefined local variable or method \'address_geo\' for main:Object
with the following rake task. What\'s the problem with it?
include Geokit::
You can use a Proc
to get the same effect without having a global method declaration. e.g.,
include Geokit::Geocoders
namespace :geocode do
desc "Geocode to get latitude, longitude and address"
task :all => :environment do
address_geo = Proc.new do
arr = []
arr << address if @spot.address
arr << city if @spot.city
arr << country if @spot.country
arr.reject{|y|y==""}.join(", ")
end
@spot = Spot.find(:first)
if @spot.latitude.blank? && !@spot.address.blank?
puts address_geo.call
end
end
end