Current gem doesn't like REE
gkop opened this issue · 2 comments
I played with the gem ~2 weeks ago and came across this:
/home/gabe/.rvm/gems/ree-1.8.7-2011.03@shady/gems/mongoid_geo-0.6.0/lib/mongoid/geo/index.rb:9:in `geo_index':
undefined method `define_singleton_method' for Spot:Class (NoMethodError)
So I bundled from git, and was able to at least start my server, but then wasn't able to do anything useful. Mostly I saw a lot of this:
RuntimeError (Invalid Geo Input. Please use either a Hash or an Array. Remember that Longitude must always be the first value in an Array.):
I took another look at my project today, and screwed with a bunch of different stuff trying to get it to work, read GH-40, so I went back to the gem, but got the same undefined method error as above.
Finally I tried the gem in Ruby 1.9.2 p180, and it worked as advertised.
I understand you're working on a release that may shortly fix this issue. But I still wanted to post this hoping to save other folks' time who are running REE.
I am working on a bit of a re-write at the moment. It is about half way through I will see if I can find sometime soon to fix this.
In a previous release I used the #define_singleton_method which is only available in Ruby 1.9+
In another project I'm using an approach more like this, which should be more portable across ruby versions.
subject_class.singleton_class.class_eval %{
def my_method
end
}
You can also use #define_method in a normal 'do' block here I think. In any case, to fix your problem just remove the part where the class method is defined. It is not really so important for normal use. Just a nice convenience method. Should have been only optionally loaded/included so as not to cause this kind of problem! Sorry!
We are working to release a much more stable and better version of this gem, hopefully this month.