[Rails] Re: NoMethodError
Ok, now I got it, the code is below, but now I have the follow error:
Attempt to call private method
I dont know if it is related with this error, but this table is a
legacy and I had to set table name and primary key.
The model is :
class Cartcid < ActiveRecord::Base
set_table_name "cartcid"
set_primary_key "NUMERO"
end
namespace :GeoFind do
desc 'Update cartcid with longitude and latitude information'
task :add_cartcid_coordinates => :environment do
include GeoKit::Geocoders
c = Cartcid.find_by_sql(["SELECT address, lat, lng FROM
cartcid WHERE ADDRESS IS NOT NULL"])
begin
c.each { |cartcid|
loc = MultiGeocoder.geocode(cartcid.address)
cartcid.lat = loc.lat
cartcid.lng = loc.lng
cartcid.update
puts "updated cartcid #{cartcid.nome}
#{cartcid.address} =>
[#{loc.lat}, #{loc.lng}]"
}
rescue
puts $!
end
end
end
--
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home