【问题标题】:rails 3 multiform geocoderrails 3 多格式地理编码器
【发布时间】:2013-01-04 23:48:58
【问题描述】:
使用来自地理编码器的 railscast 217(多步/向导)。我想要做的是让用户在表单的第一部分输入会议地点,然后在表单的第二部分让地理编码器返回地理编码器已过滤掉的地址列表。我该怎么做呢?
我已经创建了多步表单。但是我在控制器中使用什么来从表单的第一部分获取地址(街道、城市、国家),然后使用地理编码器的 near 属性在表单的第二部分返回附近位置的列表?
【问题讨论】:
标签:
ruby-on-rails-3
forms
wizard
rails-geocoder
multi-step
【解决方案1】:
想通了:
首先找到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)