Rhomobile을 사용 중이며 Alert.show_popup에있는 버튼의 ID와 제목에 대한 해시를 동적으로 만들려고 시도했지만 실제로 얻지는 못했습니다. 나는 것으로 최종 결과를 원하는 것은, 사실상이다JSON에서 루비로 다차원 배열 또는 해시 만들기
Alert.show_popup({
:message => 'Please Select Appropriate Address:',
:title => 'Get Nearby...',
:icon => :info,
:buttons => [
{'id' => '1', 'title' => 'Address 1'},
{'id' => '2', 'title' => 'Address 2'},
{'id' => '3', 'title' => 'Address 3'},
{'id' => '4', 'title' => 'Address 4'}
],
:callback => url_for(:action => :on_addressidentified_popup)
}
)
나는 몇 가지 방법을 시도했지만, 아무도 (해시 및 try_convert 등과 같은 문자열을 구축) 일 없다. 가까이에있는 것처럼 보이지만 아직 시도한 최신 하나가 여기에 있습니다.
nearbyaddresses = Rho::JSON.parse(@params['body'])
h = {}
nearbyaddresses.each do |location|
h[intIndex] = {}
h[intIndex][:id] = intIndex.to_s
h[intIndex][:title] = location["Address"].to_s
intIndex = intIndex + 1
end
Alert.show_popup({
:message => 'Please Select Appropriate Address:',
:title => 'Get Nearby...',
:icon => :info,
:buttons => h,
:callback => url_for(:action => :on_addressidentified_popup)
}
)
여기 나를 도와 줄 수있는 루비 마법사가 있습니까?
해시를 원하십니까? 'buttons'는 첫 번째 예제에서 배열입니다. –