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 7940875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:29:58+00:00 2026-06-03T23:29:58+00:00

I am using geocoder and the devise gem. And i am trying to get

  • 0

I am using geocoder and the devise gem. And i am trying to get coupons near user’s location

Coupon Model

def index
  if params[:search].present?
    @coupons = Coupon.near([user_long, user_lat], 50, :order => :distance)
  else
     @coupons = Coupon.all
  end
end 

Application Helper

I have defined the user_long and user_lat

  def user_long
           current_user.longitude
   end


   def user_lat
           current_user.latitude
   end

Devise Gem

I have tried to use the devise gem helper to get the values like so

Coupon Model

def index
  if params[:search].present?
    @coupons = Coupon.near([current_user.longitude, current_user.latitude], 50, :order => :distance)
  else
     @coupons = Coupon.all
  end
end 

I am hitting the walls and celling with this. Can someone help out, i know this is newbie question for but i can’t solve it so save my life?

  • 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-03T23:29:59+00:00Added an answer on June 3, 2026 at 11:29 pm

    My mistake was that i that i had the longitude before that latitude, It was taking away the logic

    This works.

    def index
         @coupons = Coupon.near([current_user.latitude, current_user.longitude], 50, :order => :distance)
    
    end  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the gem 'geocoder'. I am trying to make an object that
Using the Google Geocoder v3, if I try to geocode 20 addresses, I get
I'm using the android.location.Geocoder for the first time. The Idea is: I have a
I am trying to geocode multiple addresses in a model using either geokit or
I need to reverse geocode two locations from and to. Using the geocoder gem
I am trying to animate in the MapView to a location by using Location
I am using the Geocoder class to fetch multiple location objects by using the
I'm using the Geocoder and Sunspot gem in my application and I have a
I have done this function, using geocoder module, to get the city from a
I am using MKReverseGeocoder (reversegeocoder) to retrieve user's current location. I am calling reversegeocoder

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.