使用来自和地理编码器的railscast 217(多步骤/向导)。我想要做的是让用户在表单的第一部分输入会议位置,然后在表单的第二部分让地理编码器返回地理编码器已过滤掉的地址列表。我该怎么做呢?
我已经创建了多步骤表单。但是我在控制器中使用什么来从表单的第一部分获取地址(街道,城市,国家),然后使用地理编码器的near属性返回第二部分中的附近位置列表形成的?
答案 0 :(得分:0)
想出来:
首先找到railscast中的“第二”页面
elsif @order.currentplan_step == 'billing' (I placed this right after the first elsif)
#now just build a location from the previous page(form) fields
@orderlocation = params[:order][:orderaddress] + ", " + params[:order][:ordercity]
#and create a list of addresses, now you can use @findlocations to create a list of addresses you can ship to that are near your location
@findlocations = Location.near(@orderlocation, 20)