2013-01-21 5 views
0

및 geocoder에서 railscast 217 (다중 단계/마법사)을 사용합니다. 사용자가 양식의 첫 번째 부분에 회의 위치를 ​​입력하게 한 다음 양식의 두 번째 부분에 지오 코더가 필터링 한 주소 목록을 리턴하도록하십시오. 이 일을 어떻게 하죠?레일 3 다중 형식 지오 코더

이미 다단계 양식을 만들었습니다. 하지만 컨트롤러에서 폼의 첫 번째 부분에서 주소 (거리, 도시, 국가)를 가져온 다음 지오 코더의 near 속성을 사용하여 폼의 두 번째 부분에있는 가까운 위치 목록을 반환하려면 무엇을 사용해야합니까?

답변

0

이 알아 낸 :

먼저

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) 
을 청구하는 railscast에서 "두 번째"페이지를 찾을 수