ruby-on-railsruby-on-rails-3ruby-on-rails-4ruby-on-rails-5geokit

Confused on how to setup Geokit


So I've searched through all the documentation on Geokit for rails and didn't find any setup process for it except for installing the gem which I know how to do. what tables do I add to an existing "listings" table?

I've like I said, have it installed. And I've added the acts_as_mappable to the listings ruby file.

class Listing < ApplicationRecord
  acts_as_mappable
end
gem 'geokit-rails'

It would be nice if there was a video tutorial done on how to set this entire thing up.


Solution

  • You need to add a lat and lng field to your Listing model. You can do so like this:

    rails g migration add_lat_lng_to_listings lat:decimal lng:decimal

    Then migrate:

    rails db:migrate

    Once you have those fields, you should be able to do something like this:

    Listing.in_range(1..35, origin: [29.794664, -98.731970])