diff --git a/lib/geocoder/models/mongoid.rb b/lib/geocoder/models/mongoid.rb
index 9e0b9fd832127dcf2439a06786d78658d7fc9e40..763c29830bbc87cb7129832a416c4a270450679a 100644
--- a/lib/geocoder/models/mongoid.rb
+++ b/lib/geocoder/models/mongoid.rb
@@ -18,7 +18,7 @@ module Geocoder
         super(options)
         if options[:skip_index] == false
           # create 2d index
-          if (::Mongoid::VERSION >= "3")
+          if (defined? ::Mongoid::VERSION && ::Mongoid::VERSION >= "3")
             index({ geocoder_options[:coordinates].to_sym => '2d' }, 
                   {:min => -180, :max => 180})
           else