ruby-on-railsmodulegeolocationrails-geocoder

Can't use Geocoder class in my controller


I have such trouble: I want to use ajax request to get user location, so I created action in my controller and rendering the result of Geocoder function in json. Here is code:

  def find_location
   location = Geocoder.coordinates(params[:location])
   render :json => (location)
  end

Locally it works great, on heroku it works too, but when I added this code to another project - it shows me this error

   NameError in ConnectionsController#find_location

   uninitialized constant ConnectionsController::Geocoder

It is strange, because this is working in console:

      Geocoder.coordinates "Ukraine"
       => [48.379433, 31.16558] 

I tried to include Geocoder::Model, but it doesn't work.

Can someone help me ?


Solution

  • Based on this issue you have to restart the whole production machine, not only your apache or nginx.

    I actually had to open an issue because it doesn't work for me. https://github.com/alexreisner/geocoder/issues/501