Rails inner join combined with geocoding gem

笑着哭i 提交于 2019-12-03 15:18:34
user3735351
near = Location.near(location, radius)
Rate.includes(:location).references(:location).merge(near)

This is chainable with other Location or Rate scopes

I know this is an old one, but still not answered, nowhere :)

I ran into the same Problem, then stumbled upon a little info deep down in the geocoder documentation, where it said that in order to make an outer join work (which in rails is done with includes), you should use join in combination with :select and that did it for me (I needed to find all the products from users within a certain location).

So just from the top of my head, this might work in your case:

rates = Location.near(my_latitude, my_longitude, distance, :select => "rates.*").joins(:locations).where(:rates => {:pair => 'xxxx'})

I hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!