Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8403367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:19:27+00:00 2026-06-09T22:19:27+00:00

I am working on a new project and whole day thinking & looking for

  • 0

I am working on a new project and whole day thinking & looking for the best way, how to save users’ location to database.

I need to save their city, country. Here is a bit problem, because for example for Europeans this means city=Berlin, country=Germany.
But for US users it’s like city=Los Angeles, country=California (state=USA).

So this is the problem with which I ma facing whole today.

My goal in this app is to find all users in the city according to their location. And also find the people, which are in their area of let’s say 15 km/miles.

I plan to implement the app in RoR, PostgreSQL, the app will run probably on Heroku.

What is the best way to solve this “problem”? Could you give me please some advices, tips, whatever?

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:19:28+00:00Added an answer on June 9, 2026 at 10:19 pm

    You can use the geokit and geokit-rails gems to achieve that. See here for documentation: https://github.com/imajes/geokit-rails

    Basically, it works like this: you save address data of your users and that address is looked up and mapped to a point in space (lat/lng) using a geocoding service (e.g. Google Maps or Yahoo Placefinder). These points can then be used to calculate distances etc.

    An example:

    class User < ActiveRecord::Base
      # has the following db fields:
      # - city
      # - state
      # - country
      # - latitude
      # - longitude
    
      acts_as_mappable :default_units       => :miles, 
                       :default_formula     => :sphere, 
                       :lat_column_name     => :latitude,
                       :lng_column_name     => :longitude,
                       :auto_geocode        => {:field => :full_address}
    
      def full_address
        [city, state, country].reject(&:blank).join(', ')
      end
    end
    

    Then you can do the following:

    # find all users in a city (this has nothing to do with geokit but is just a normal db lookup)
    User.where(:city => 'New York')
    
    # find all users that are within X miles of a place
    User.find_within(300, 'Denver')
    

    and much more, just see the documentation…

    This example shows you how to use the geokit gem. This gem does no longer seem to be under active development. So maybe it would be worthwile to check out geocoder: https://github.com/alexreisner/geocoder

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a new project, a web application, where I need to focus
I am working on a new project for a client; they have supplied the
I'm working on a new project where I want to use Phil Haack Areas
I'm working on a new project and for some reason decided to create two
I'm working on a new project with a full ANT build. I use eclipse
I'm working on a new project http://www.hotwirerevealed.com which reveals / identifies hotels on hotwire.com.
We are working on a new project with Grails 2.0.1 and Spring Security. The
I'm coming from a MS SQL Server background. Working on a new project using
We are working on a new web project that is just loose html/css/js files
I'm working on a new Django project, and the client wants to feature content

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.