Tag: rails

如何使用ruby获得两个坐标之间的汽车路线?

我正在使用谷歌地图和汽车路线开发rails应用程序。 我有一个汽车路线的起点和终点 – 两个坐标。 如何获得完整的汽车路线(汽车通过街道的坐标系列)? 我可以使用gmaps4rails和geocoder吗? 像这样的东西: start_point = [41,2423; 45,323452] end_point = [42,2423; 42,323452] full_route = some_method_for_calculate_route( start_point, end_point ) #paint line on map from array of points paint_line( full_route ) 请帮忙,谢谢你:)

太阳黑子`LIKE`查询

我正在使用sunspot 。 如何运行LIKE查询( LIKE %q% )? 我想做这样的事情: @search = Sunspot.search(User) do |q| q.text_fields { with(:company_name).like(params[:q]) } end.results 代替: @search = Sunspot.search(User) do |q| q.text_fields { with(:company_name).starting_with(params[:q]) } end.results 这部分对我有用。 回顾sunspot代码,我找到了这段代码: class StartingWith < Base private def to_solr_conditional "#{solr_value(@value)}*" end end 它基本上生成以下太阳黑子搜索哈希: Sunspot.search(User) do |q| q.text_fields { with(:company_name).starting_with(“sta”)} } end => Sunspot::Search:{:q=>”*:*”, :fq=>[“type:User”, “company_name_text:sta*”]} 如果没有更简单的方法来实现LIKE %query% […]