Prabesh Shrestha
Prabesh Shrestha

Reputation: 2742

get nearby locations of certain location with mongoid or rubygeocode

I have something like

@office = Office.first
@offices = Office.where(:status => "active")

How do I get offices near @office from above variables, i.e I want something like

@offices.near(@office.latitude, @office.longitude) or
Office.near([@office.latitude, @office.longitude]).where(:status=>"active")

I can get this with @office.nearbys( with rubygeocoder) but that is not an option for me right now, I need to utilize a near method on the collection to get offices near a given office.

Or is there other gems I can use to do this if not possible with rubygeocoder or mongoid ? Thanks .

Upvotes: 0

Views: 117

Answers (1)

Prabesh Shrestha
Prabesh Shrestha

Reputation: 2742

I tried to find other solution but at last I am going with

@offices = @office.nearbys

At it does the work evenif not the way I wanted it to .

Upvotes: 1

Related Questions