Is there a way to NOT limit the distance to the target position and only order by distance?
I'm currently doing something like this:
@positions = Position.near(@user_position.coordinates, 999999).order(:distance).paginate(page: params[:page])
But as a programmer, It feels not right to use something like this.
It would be great if there exists something like:
@positions = Position.near(@user_position.coordinates, :no_limit).order(:distance).paginate(page: params[:page])
I hope somebody can help me.
It's not as unfriendly to programmer as it seems. If you worked with C, for example, you know that there is no exact definition of range of int
. Even for Java, where the size is precise, it's still limited and you should not forget about it.
If you want you query be more readable, define NO_LIMIT = 999999
constant and use it in place of :no_limit
.
There is an answer from creator of geocoder
on similar issue:
I think your best bet is to use a very large radius.
So there are probably no way around it.