Ruby on Rails 中的 Geokit,距离查找器,如何按最近到最远排序?
我正在使用 Geokit。我的模型中有以下内容:
# Distance-based finder method
# Usage:
# - find_this_within(Shop.first, 10)
def self.find_this_within(origin, within)
if origin.geocoded?
find(:all, :origin => origin, :within => within )
else
[]
end
end
然后在我的控制器中:
@shops = s.paginate(:page => params[:page], :per_page => 20)
当前输出按 ID 升序列出。我希望它从最近到最远排序。我应该怎么办?
谢谢。
I'm using Geokit. I have the following in my model:
# Distance-based finder method
# Usage:
# - find_this_within(Shop.first, 10)
def self.find_this_within(origin, within)
if origin.geocoded?
find(:all, :origin => origin, :within => within )
else
[]
end
end
Then in my controller:
@shops = s.paginate(:page => params[:page], :per_page => 20)
Currently the output is listed in ID ascending. I want it to sort from nearest to furthest. What should I do?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信您正在寻找的是:
或者说文档: http://geokit.rubyforge.org/
I believe what you are looking for is:
Or so say the Docs: http://geokit.rubyforge.org/