Hi there!
Im new on ruby/rails, and im tying to run the rake task below but I
got an error. After I tested on script/console and I got the same
error. Could you helpe me, please?
Thanks!
Pedro
Rake Task:
namespace :meuApp do
desc 'Update geotable with longitude and latitude information'
task :add_geotable_coordinates => :environment do
include GeoKit::Geocoders
geotable = Geotable.find_by_sql(["SELECT * FROM geotable WHERE
ADDRESS IS NOT NULL"])
begin
geotable.each { |geotable|
loc = MultiGeocoder.geocode(geotable.address)
geotable.lat = loc.lat
geotable.lng = loc.lng
geotable.update
puts "updated cartcid #{geotable.NOME}
#{geotable.address} =>
[#{loc.lat}, #{loc.lng}]"
}
rescue
puts $!
end
end
end
The script/console test:
>>Geotable.find_by_sql(["SELECT * FROM geotable WHERE ADDRESS IS NOT
NULL"])
....
.... data retrieved ommited
......
>> @geotable.address
NoMethodError: undefined method `address' for #<Array:0x4712fa0>
from (irb):27
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment