我想解析一個JSON結構到數據庫使用rhonobile和我的代碼如下;解析json與rhomobile
def GetTopGainers
Rho::AsyncHttp.get(
:url => 'http://www.xyz.com/xyz',
:callback => (url_for :action => :httpget_callback),
:callback_param => "")
redirect :action => :viewhttp
end
def httpget_callback
$httpresult = @params['body'][0].inspect
@params['body'].each do |dailygainers|
mygainer = Topgainers.new
mygainer.gainers = Topgainers["dailygainers"]["gainers"]
mygainer.date = Topgainers["dailygainers"]["date"]
mygainer.open = Topgainers["dailygainers"]["Open"]
mygainer.close = Topgainers["dailygainers"]["Close"]
mygainer.save
end
WebView.refresh
end
問題是什麼都沒有保存到數據庫。
任何想法?