apneadiving / Google-Maps-for-Rails

Enables easy Google map + overlays creation in Ruby apps
https://apneadiving.github.io/
MIT License
2.26k stars 382 forks source link

Fix! DEPRECATION WARNING: The InstanceMethods module inside ActiveSupport::Concern will be no longer included automatically. #241

Closed kristianmandrup closed 12 years ago

kristianmandrup commented 12 years ago

Been spending the whole day trying to fix this deprecation warning in my Rails project:

DEPRECATION WARNING: The InstanceMethods module inside ActiveSupport::Concern will be no longer included automatically. Please define instance methods directly in Mongoid::Document instead. (called from include at /Users/kmandrup/test_model/app/models/user.rb:2)

I finally tracked it down to an issue with the ActsAsGmappable module implementation. I changed it to use the following convention and now the deprecation warning disappears for all my models :)

Also this refactoring is a much better convention than the "old style"...


module Gmaps4rails
  module ActsAsGmappable
    extend ActiveSupport::Concern    

    # This is a validation method which triggers the geocoding and save its results
    def process_geocoding
      Gmaps4rails::ModelHandler.new(self, gmaps4rails_options).retrieve_coordinates
    end

    # creates json for one instance 
    def to_gmaps4rails(&block)
      json = "["
      object_json = Gmaps4rails.create_json(self, &block)
      json << object_json.to_s unless object_json.nil?
      json << "]"
    end

    module ClassMethods
       ...
    end
end

So please make this fix ;)

apneadiving commented 12 years ago

Closed as fixed by @kristianmandrup in 1.5.4