2013-01-21 41 views
0

使用来自地理编码器的railscast 217(多步骤/向导)。我想要做的是让用户在表单的第一部分输入会议位置,然后在表单的第二部分输入geocoder返回地址解析器已过滤出的地址列表。我会如何去做这件事?导轨3多种形式的地理编码器

我已经创建了多步表单。但是我在控制器中使用什么来从表单的第一部分获取地址(街道,城市,国家),然后使用geocoder的near属性返回表单第二部分中的附近位置列表?

回答

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) 
“第二” 页面