我正在尝试使用 rhonobile 将 JSON 结构解析到数据库中,我的代码如下;
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
问题是没有任何东西被保存到数据库中。
有任何想法吗?