> namespace :Geo 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  FROM cartcid WHERE
> ADDRESS IS NOT NULL"])
>             begin
>                 c.each { |cartcid|
>                     loc = MultiGeocoder.geocode(c.address)
>                     c.lat = loc.lat
>                     c.lng = loc.lng
>                     c.update
>                     puts "updated cartcid #{c.nome} #{c.address} =>
>                     [#{loc.lat}, #{loc.lng}]"
>                 }
>                 rescue
>                 puts $!
>              end
>      end
> end

Still wrong... you did the exact same thing as before in another way...

>         c = Cartcid.find_by_sql(["SELECT address  FROM cartcid WHERE

Given your code, "c" is an array (of Cardcid's) - and the Array class 
does not have an address attribute.

>                 c.each { |cartcid|

Given this line, you are processing each individual element in "c" in a 
variable named "cartcid"

>                     loc = MultiGeocoder.geocode(c.address)

Now you are referencing the array "c" again!!! Just like you were doing 
in your earlier post.  That line needs to be:

loc = MultiGeocoder.geocode(cartcid.address)

-- 
Posted via http://www.ruby-forum.com/.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to