# Problem using GeoKit plugin from rake task

**URL:** <https://www.ruby-forum.com/t/problem-using-geokit-plugin-from-rake-task/147471>\
**Category:** Rails\
**Created:** [September 2, 2008, 8:57am UTC](https://www.ruby-forum.com/t/problem-using-geokit-plugin-from-rake-task/147471 "2008-09-02T08:57:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cheeseprophet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c67d28/32.png) [@cheeseprophet](https://www.ruby-forum.com/u/cheeseprophet)\
**Post date:** [September 2, 2008, 8:57am UTC](https://www.ruby-forum.com/t/problem-using-geokit-plugin-from-rake-task/147471/1 "2008-09-02T08:57:33Z")

</div>

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
