rails-geocoder

Geocoder: How get all results and order by distance?

陌路散爱 提交于 2019-12-01 19:27:26
I know how to use the near method to get all results within a certain radius, but how do I get all results and order by distance? I know I could do something like this: Location.near(my_location, 999999, order: 'distance') However, I would rather skip the radius check altogether and simply get all results sorted by distance. I have had the same issue, and I ended up adding this scope to my geocoded class: class A extend Geocoder::Model::ActiveRecord reverse_geocoded_by :latitude, :longitude scope :with_distance_to, ->(point) { select("#{table_name}.*").select("(#{distance_from_sql(point)}) as

undefined method `model_name' for TrueClass:Class for DeviseConfirmations (Rails 4, devise)

自古美人都是妖i 提交于 2019-12-01 14:31:47
In my Rails app, in order to save user country (using Geocoder gem) into the User table when the user signs up, and using another SO question , I have changed something in my controllers/confirmations_controller.rb but am getting a serious error I don't understand nor manage to solve: def after_sign_up_path_for(resource) if Devise.allow_insecure_sign_in_after_confirmation resource.update(user_country: request.location.country) after_sign_in_path_for(resource) else resource.update(user_country: request.location.country) root_path end end What's weird is that the user is saved with everything

Show markers on google maps dynamically -Rails 3.2

。_饼干妹妹 提交于 2019-12-01 02:00:52
i have a working code that shows multiple markers on google map using geocoder such as @nearbys = Place.near("#{params[:address]}", 5,:order => "distance",:units => :km) @nearbys.first(5) and i display the markers using the below code function initialize() { var map; var bounds = new google.maps.LatLngBounds(); var mapOptions = { mapTypeId: 'roadmap' }; // Display a map on the page map = new google.maps.Map(document.getElementById("map-canvas-guest"), mapOptions); map.setTilt(45); // adding Multiple Markers from ruby object var markers = [ ['<%= @nearbys[0].title %>', '<%= @nearbys[0].latitude

Show markers on google maps dynamically -Rails 3.2

拜拜、爱过 提交于 2019-11-30 20:37:50
问题 i have a working code that shows multiple markers on google map using geocoder such as @nearbys = Place.near("#{params[:address]}", 5,:order => "distance",:units => :km) @nearbys.first(5) and i display the markers using the below code function initialize() { var map; var bounds = new google.maps.LatLngBounds(); var mapOptions = { mapTypeId: 'roadmap' }; // Display a map on the page map = new google.maps.Map(document.getElementById("map-canvas-guest"), mapOptions); map.setTilt(45); // adding

geocoding api not responding fast enough for IP address

给你一囗甜甜゛ 提交于 2019-11-29 17:21:17
In my production server I've used the Geocoder gem. But, the following code not working in the server console. Geocoder.search("192.168.1.4") I've configured my geocoder.rb file with timeout 30 seconds. But still it gives the error geocoding api not responding fast enough Surprisingly, whenever i ran Geocoder.search("San Francisco, CA") it gives the result within seconds. What should i do? I think it is an issue with freegeoip, try the following: Enter this in your rails console: Geocoder.configure(:ip_lookup => :telize) Now try you search in your console. if this works you can have your file