Sha256: c6f5537c1bb5799669100a86f07da433187d583851281b427f71d19e32b7e309
Contents?: true
Size: 633 Bytes
Versions: 8
Compression:
Stored size: 633 Bytes
Contents
namespace :geocode do desc "Geocode all objects without coordinates." task :all => :environment do class_name = ENV['CLASS'] || ENV['class'] raise "Please specify a CLASS (model)" unless class_name klass = class_from_string(class_name) klass.not_geocoded.each do |obj| obj.geocode; obj.save end end end ## # Get a class object from the string given in the shell environment. # Similar to ActiveSupport's +constantize+ method. # def class_from_string(class_name) parts = class_name.split("::") constant = Object parts.each do |part| constant = constant.const_get(part) end constant end
Version data entries
8 entries across 8 versions & 2 rubygems