我正在尝试在我的控制器中执行某些操作后加载视图,我收到视图已加载的消息,但视图从未显示
我的控制器:
def getBalance
@result
accountId = params['accountId']
baseURLUpdate = 'http://xxxxxxxxxx' + accountId + '/statement'
transactionHash = generateTransactionHash(accountId)
@result = HTTParty.get(baseURLUpdate.to_str,
:headers => { 'Content-Type' => 'application/json',
'Api-Access-Key' => 'xxxxxxxx',
'Transaction-Hash' => transactionHash } )
puts @result
redirect_to accounts_response_path(:result => @result)
return
end
我的路线:
post 'accounts/getBalance', to: "accounts#getBalance"
get 'accounts/response', to: "accounts#responseShow"
我的观点名为responseShow.html.erb,我也有一个response.html.erb。
我得到了这个:
Redirected to http://localhost:3000/accounts/response.html
Completed 302 Found in 409ms (ActiveRecord: 0.0ms)
Started GET "/accounts/response.html" for 127.0.0.1 at 2016-01-19 10:36:02 -0200
Processing by AccountsController#response_show as HTML
I'm here
Rendered accounts/response_show.html.erb within layouts/application (0.0ms)
Completed 200 OK in 18ms (Views: 17.2ms | ActiveRecord: 0.0ms)
答案 0 :(得分:3)
您可以尝试使用控制器中的格式块:
respond_to do |format|
format.html {redirect_to accounts_response_path(:result => @result)}
format.js {render :js => "window.location.href='"+accounts_response_path(:result => @result)+"'"}
end