rails-geocoder

Geocoder to work with two addresses

孤街醉人 提交于 2020-02-25 23:27:12
问题 rails 4.1.3 application with Geocoder gem has the following attributes on a model t.decimal :origin_lon, :precision => 15, :scale => 10 t.decimal :origin_lat, :precision => 15, :scale => 10 t.point :origin_lonlat, :srid => 3857 t.decimal :destination_lon, :precision => 15, :scale => 10 t.decimal :destination_lat, :precision => 15, :scale => 10 t.point :destination_lonlat, :srid => 3857 The model is defined with geocoded_by :origin, :latitude => :origin_lat, :longitude => :origin_lon geocoded

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

余生颓废 提交于 2020-01-21 10:26:11
问题 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:

undefined method `merge' for “xxxxxx”:String rails form_for

坚强是说给别人听的谎言 提交于 2020-01-04 14:30:39
问题 I have this form in /new.html.erb: <%= form_for @vendor, multipart: true do |f| %> <%= f.text_field :name, "Store Name" %> <%= f.text_field :address, "Store Address" %> <%= f.file_field :image %> <%= f.submit "Save", class: "btn btn-success" %> <% end %> and these Vendor methods: def new @vendors = Vendor.all @vendor = Vendor.new end def vendor_params params.require(:vendor).permit(:id, :name, :latitude, :longitude, :address, :image) end When I try to render the page, I get this error:

Ruby Geocoder gem to find postal code

放肆的年华 提交于 2020-01-03 18:51:47
问题 I'm using the ruby geocoder gem to search by location. I want to limit searches to locations that have officially launched. If someone searches by zip, this is easy using a regex. But if someone searches by city, I need to convert the city into a zip code, check my zip table and if positive, return the search results. The geocoder api has a section for reverse geocoding: reverse_geocoded_by :latitude, :longitude do |obj,results| if geo = results.first obj.city = geo.city obj.zipcode = geo

getting latitude and longitude values from controller in rails-geocoder gem

帅比萌擦擦* 提交于 2020-01-03 03:01:14
问题 Is it possible to get latitude and longitude values in the controller when using geocoder gem in rails? What am currently doing for getting all nearby location is pass the location name like below. event_address = Event.near(location, 15, order: 'distance') So is there a way to fetch the lat and lng which was used for the above requested location for using later in subsequent requests for same location? @latitude= #some method @longitude= #some_method 回答1: Geocoder.coordinates(location) for

Can Ruby Geocoder return just the street name on reverse_geocode calls?

巧了我就是萌 提交于 2020-01-02 05:50:46
问题 The geocoder gem will automatically reverse geocode on save if the line after_validation :reverse_geocode is included in the model. This results in a long string of text being saved as the address, though - the format is something like "Street Name, City Name, County Name, State Name, Zip Code, Country Name". I'm only interested in the street name for this particular project, so I'm wondering if there's a way to modify the after_validation call to only save that information. If I do the

Searching location by IP using Geocoder gem not working properly with rails 4

二次信任 提交于 2019-12-24 12:34:32
问题 I have added geocoder gem in my rails application but it is not responding properly when i am searching location by IP. The problem is that it's returning nil array. Geocoding API's response was not valid JSON. [] But sometimes it's working, I don't know why. What I have done: Gemfile gem 'geocoder' initializers/geocoder.rb Geocoder.configure( :timeout => 20, :lookup => :google, #:ip_lookup => :google, #:api_key => "xxxx-xxx", :units => :km ) application_controller.rb def current_location if

Receiving the error PG::UndefinedColumn: ERROR: column mymodels.distance does not exist when using Geocoder's near method

懵懂的女人 提交于 2019-12-23 11:44:18
问题 When using this query (the same as in Railscasts episode #273): @locations = Location.near(params[:search], 50, :order => :distance) Or, to be more concise: @mymodels = MyModel.near(address, distance, order: :distance) I get the error: PG::UndefinedColumn: ERROR: column mymodels.distance does not exist The distance column is supposed to be added to the results by the Geocoder gem but it does not appear to appear in the results (so I get the above error). 回答1: When using Postgres along with

Receiving the error PG::UndefinedColumn: ERROR: column mymodels.distance does not exist when using Geocoder's near method

懵懂的女人 提交于 2019-12-23 11:44:07
问题 When using this query (the same as in Railscasts episode #273): @locations = Location.near(params[:search], 50, :order => :distance) Or, to be more concise: @mymodels = MyModel.near(address, distance, order: :distance) I get the error: PG::UndefinedColumn: ERROR: column mymodels.distance does not exist The distance column is supposed to be added to the results by the Geocoder gem but it does not appear to appear in the results (so I get the above error). 回答1: When using Postgres along with

How get car route between two coordinates using ruby?

*爱你&永不变心* 提交于 2019-12-23 04:22:12
问题 I'm developing rails app with google maps and car routes. I have a start and finish points for car route - two coordinates. How can I get a full car route (array of coordinates for car through streets)? Can I do it using gmaps4rails and geocoder ? Something like this: start_point = [41,2423; 45,323452] end_point = [42,2423; 42,323452] full_route = some_method_for_calculate_route( start_point, end_point ) #paint line on map from array of points paint_line( full_route ) Please help, thanks