From bf911edd4357b54d483383b1a79bfc5332c6ed9f Mon Sep 17 00:00:00 2001 From: Mike Park <mikep@quake.net> Date: Wed, 9 Mar 2011 15:22:36 +0100 Subject: [PATCH] delay evaluation of geocoder_options the scope is defined before geocoder_options have been initialized. --- lib/geocoder/orms/active_record.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/geocoder/orms/active_record.rb b/lib/geocoder/orms/active_record.rb index c00f5ddc..61efacdc 100644 --- a/lib/geocoder/orms/active_record.rb +++ b/lib/geocoder/orms/active_record.rb @@ -17,14 +17,14 @@ module Geocoder::Orm base.class_eval do # scope: geocoded objects - scope :geocoded, - :conditions => "#{geocoder_options[:latitude]} IS NOT NULL " + - "AND #{geocoder_options[:longitude]} IS NOT NULL" + scope :geocoded, lambda { + {:conditions => "#{geocoder_options[:latitude]} IS NOT NULL " + + "AND #{geocoder_options[:longitude]} IS NOT NULL"}} # scope: not-geocoded objects - scope :not_geocoded, - :conditions => "#{geocoder_options[:latitude]} IS NULL " + - "OR #{geocoder_options[:longitude]} IS NULL" + scope :not_geocoded, lambda { + {:conditions => "#{geocoder_options[:latitude]} IS NULL " + + "OR #{geocoder_options[:longitude]} IS NULL"}} ## # Find all objects within a radius (in miles) of the given location -- GitLab