I''m still learning rails and I''ve run into a problem that has
me
baffled and google hasn''t been able to help.
I''m using the GeoKit plugin to handle the geocoding of one of my
models. The model has a method called do_geocode(addr) that takes an
address string (addr), does the geocoding and assigns the appropriate
attributes based on the response. I''ve tested this quite a bit using
my web interface and have had no problems. Now, though, I''m trying to
do geocoding from a rake task, and this method always mysteriously
fails. The rake task reads in an address string from a file and calls
go_geocode on the model object.
Are rake tasks not able to utilize the full functionally of models
that have plugin functionality mixed in? The rake task code is
included below:
require ''csv''
namespace :util do
desc ''Import CSV file of stuff''
task(:import => :environment) do
CSV::Reader.parse(File.open(''./lib/tasks/test.csv'',
''r'')) do |row|
store = Store.new do |c|
c.name = row[0]
c.phone = row[1]
addr = row[2]
c.do_geocode(addr)
end
if store.valid? # It is never valid because do_geocode always
fails
puts ''Store is valid''
else
store.errors.each_full{ |msg| puts msg }
end
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---