我有这个控制器在我的开发环境中工作。它由用户点击链接并生成.rdp
以供下载触发。但是,在我的开发环境中工作时,尝试在 Heroku 上使用它时,我将被重定向到根页面。
我刚刚对 heroku 进行了git push
,它告诉我一切都是最新的。
我的控制器
def createrdpfile
jumpsquare = Jumpsquare.find(params[:id])
file = Tempfile.new(jumpsquare.ipordns.to_s + '.rdp')
file.write("screen mode id:i:2
desktopwidth:i:1436
desktopheight:i:925
session bpp:i:16
auto connect:i:1
full address:s:" + jumpsquare.ipordns.to_s + "
compression:i:1
keyboardhook:i:2
audiomode:i:2
redirectdrives:i:0
redirectprinters:i:0
redirectcomports:i:0
redirectsmartcards:i:0
displayconnectionbar:i:1
alternate shell:s:
shell working directory:s:
disable wallpaper:i:1
disable full window drag:i:1
disable menu anims:i:1
disable themes:i:1
bitmapcachepersistenable:i:1
winposstr:s:0,3,0,0,800,600
redirectclipboard:i:1
redirectposdevices:i:0
drivestoredirect:s:
autoreconnection enabled:i:1
authentication level:i:0
prompt for credentials:i:0
negotiate security layer:i:1
remoteapplicationmode:i:0
allow desktop composition:i:0
allow font smoothing:i:0
disable cursor setting:i:0
gatewayhostname:s:
gatewayusagemethod:i:0
gatewaycredentialssource:i:4
gatewayprofileusagemethod:i:0"
)
file.close
send_file(file.path, :filename => jumpsquare.ipordns.to_s + '.rdp', :type=>'application/rdp')
#send_file file.path, :type=>'application/rdp'
end
heroku tail log
2013-12-08T03:54:50.830006+00:00 app[web.1]: Started GET "/jumpsquares/286/createrdpfile" for 99.53.77.161 at 2013-12-08 03:54:50 +0000
2013-12-08T03:54:50.830729+00:00 app[web.1]: Started GET "/jumpsquares/286/createrdpfile" for 99.53.77.161 at 2013-12-08 03:54:50 +0000
2013-12-08T03:54:50.835417+00:00 app[web.1]: Processing by JumpsquaresController#createrdpfile as HTML
2013-12-08T03:54:50.835417+00:00 app[web.1]: Processing by JumpsquaresController#createrdpfile as HTML
2013-12-08T03:54:50.835657+00:00 app[web.1]: Parameters: {"id"=>"286"}
2013-12-08T03:54:50.835657+00:00 app[web.1]: Parameters: {"id"=>"286"}
2013-12-08T03:54:50.878697+00:00 app[web.1]: Redirected to http://www.jumpsquares.net/jumpsquares
2013-12-08T03:54:50.878697+00:00 app[web.1]: Redirected to http://www.jumpsquares.net/jumpsquares
2013-12-08T03:54:50.879290+00:00 app[web.1]: Completed 302 Found in 43ms (ActiveRecord: 7.6ms)
2013-12-08T03:54:50.879290+00:00 app[web.1]: Completed 302 Found in 43ms (ActiveRecord: 7.6ms)
2013-12-08T03:54:50.888283+00:00 heroku[router]: at=info method=GET path=/jumpsquares/286/createrdpfile host=www.jumpsquares.net fwd="99.53.77.161" dyno=web.1 connect=2ms service=60ms status=302 bytes=104
2013-12-08T03:54:51.072305+00:00 app[web.1]: Started GET "/jumpsquares" for 99.53.77.161 at 2013-12-08 03:54:51 +0000
2013-12-08T03:54:51.073470+00:00 app[web.1]: Started GET "/jumpsquares" for 99.53.77.161 at 2013-12-08 03:54:51 +0000
2013-12-08T03:54:51.075021+00:00 app[web.1]: Processing by JumpsquaresController#index as HTML
2013-12-08T03:54:51.076274+00:00 app[web.1]: Processing by JumpsquaresController#index as HTML
2013-12-08T03:54:51.304897+00:00 app[web.1]: Rendered jumpsquares/index.html.erb within layouts/application (186.4ms)
2013-12-08T03:54:51.305084+00:00 app[web.1]: Rendered jumpsquares/index.html.erb within layouts/application (186.4ms)
2013-12-08T03:54:51.319162+00:00 app[web.1]: Rendered layouts/_header.html.erb (12.8ms)
2013-12-08T03:54:51.319270+00:00 app[web.1]: Rendered layouts/_header.html.erb (12.8ms)
2013-12-08T03:54:51.321032+00:00 app[web.1]: Rendered layouts/_footer.html.erb (0.2ms)
2013-12-08T03:54:51.321106+00:00 app[web.1]: Rendered layouts/_footer.html.erb (0.2ms)
2013-12-08T03:54:51.321501+00:00 app[web.1]: Completed 200 OK in 245ms (Views: 144.5ms | ActiveRecord: 71.3ms)
2013-12-08T03:54:51.321899+00:00 app[web.1]: Completed 200 OK in 245ms (Views: 144.5ms | ActiveRecord: 71.3ms)
2013-12-08T03:54:51.331901+00:00 heroku[router]: at=info method=GET path=/jumpsquares host=www.jumpsquares.net fwd="99.53.77.161" dyno=web.1 connect=2ms service=378ms status=200 bytes=27976
答案 0 :(得分:0)
您不必将其写入文件即可发送,只需立即发送send_data
:
def createrdpfile
jumpsquare = Jumpsquare.find(params[:id])
data = "screen mode id:i:2
desktopwidth:i:1436
desktopheight:i:925
session bpp:i:16
auto connect:i:1
full address:s:" + jumpsquare.ipordns.to_s + "
compression:i:1
keyboardhook:i:2
audiomode:i:2
redirectdrives:i:0
redirectprinters:i:0
redirectcomports:i:0
redirectsmartcards:i:0
displayconnectionbar:i:1
alternate shell:s:
shell working directory:s:
disable wallpaper:i:1
disable full window drag:i:1
disable menu anims:i:1
disable themes:i:1
bitmapcachepersistenable:i:1
winposstr:s:0,3,0,0,800,600
redirectclipboard:i:1
redirectposdevices:i:0
drivestoredirect:s:
autoreconnection enabled:i:1
authentication level:i:0
prompt for credentials:i:0
negotiate security layer:i:1
remoteapplicationmode:i:0
allow desktop composition:i:0
allow font smoothing:i:0
disable cursor setting:i:0
gatewayhostname:s:
gatewayusagemethod:i:0
gatewaycredentialssource:i:4
gatewayprofileusagemethod:i:0"
send_data(data, :filename => jumpsquare.ipordns.to_s + '.rdp', :type=>'application/rdp')
end