A rails app which gets users location using HTML5 geolocation and saves to data base

后端 未结 3 1942
执笔经年
执笔经年 2021-02-02 04:40

Seems pretty simple but I\'m struggling.

Here\'s what I have so far in the view. I display the location coords just to test its working. But I also want to persist on Da

3条回答
  •  无人及你
    2021-02-02 05:27

    You can try an "easier" way, use geocoder gem, this provides multiple methods in order to fetch the user location, one of them is by request.

    request.location.city => Medellin
    request.location.country => Colombia
    

    You can find useful information in the following links

    Railscast

    Official WebPage

    GitHub

提交回复
热议问题