![](/img/trans.png)
[英]How do I order the results of rails geocoder gem by something other than distance
[英]Rails Geocoder custom order result other than distance
我正在使用Geocoder( https://github.com/alexreisner/geocoder )来查找附近的商店,例如:Store.near([@ lat,@long],20)可以通过id对我的结果进行排序距离?
通过顺序求解:Near方法中为false
另外,您可以使用reorder
而不是order
来对near
结果应用任何排序顺序: Store.near([@lat, @long], 20).reorder(:id)
reorder
将替换先前范围创建的order
声明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.