使用 heroku 上的 sinatra 应用程序重定向
Redirects with a sinatra app on heroku
我有一个 Tictactoe 游戏,是为我正在上的课程制作的,我已将我的应用程序部署到 heroku。它在我的本地主机上运行良好,但是当我在线播放时,它不喜欢我使用的重定向。重定向到('/status'),这是我要检查是否有胜利或平局的地方,如果没有,它会让 ai 或第二个玩家选择一个正方形。我该如何解决这个问题,或者如果有人可以指出 link 那会很酷。我现在找了一段时间,似乎找不到。
post '/game' do
choice = params[:choice].to_i
player_marker = players.current_player()
if play_board.square_available?(choice - 1) == true
play_board.board[choice - 1] = player_marker
redirect to('/status')
else
erb :squares, :locals => {:p1 => players.player1,
:p2 => players.player2,
:invaild => "Hey #{players.current} #{choice} is already taken",
:message2 => "Please choose again.",
:current => players.current,
:board => play_board.board,
:type => players.type}
end
end
2015-12-21T03:06:29.194376+00:00 app[web.1]: https://mmtictactoe.herokuapp.com /squares -> /style.css
2015-12-21T03:06:32.382665+00:00 heroku[router]: at=info method=POST path="/game" host=mmtictactoe.herokuapp.com request
_id=b6b0abdb-783d-4111-99e4-244c1730179a fwd="75.89.86.120" dyno=web.1 connect=1ms service=18ms status=500 bytes=231
2015-12-21T03:06:32.361241+00:00 app[web.1]: NoMethodError - undefined method `to' for #<Sinatra::Application:0x007f05bd
0dae20>:
redirect to
是在 2011 年的 Sinatra 1.2 中引入的。如果你没有这个,你的 Heroku 服务器上一定是 运行 一个非常旧的 Sinatra 版本。
采取 look here for getting started with Heroku,并确保您的 Gemfile 具有 Sinatra 1。4.x(在回答此问题时最新)指定:
gem 'sinatra', '~>1.4.0'
我有一个 Tictactoe 游戏,是为我正在上的课程制作的,我已将我的应用程序部署到 heroku。它在我的本地主机上运行良好,但是当我在线播放时,它不喜欢我使用的重定向。重定向到('/status'),这是我要检查是否有胜利或平局的地方,如果没有,它会让 ai 或第二个玩家选择一个正方形。我该如何解决这个问题,或者如果有人可以指出 link 那会很酷。我现在找了一段时间,似乎找不到。
post '/game' do
choice = params[:choice].to_i
player_marker = players.current_player()
if play_board.square_available?(choice - 1) == true
play_board.board[choice - 1] = player_marker
redirect to('/status')
else
erb :squares, :locals => {:p1 => players.player1,
:p2 => players.player2,
:invaild => "Hey #{players.current} #{choice} is already taken",
:message2 => "Please choose again.",
:current => players.current,
:board => play_board.board,
:type => players.type}
end
end
2015-12-21T03:06:29.194376+00:00 app[web.1]: https://mmtictactoe.herokuapp.com /squares -> /style.css
2015-12-21T03:06:32.382665+00:00 heroku[router]: at=info method=POST path="/game" host=mmtictactoe.herokuapp.com request
_id=b6b0abdb-783d-4111-99e4-244c1730179a fwd="75.89.86.120" dyno=web.1 connect=1ms service=18ms status=500 bytes=231
2015-12-21T03:06:32.361241+00:00 app[web.1]: NoMethodError - undefined method `to' for #<Sinatra::Application:0x007f05bd
0dae20>:
redirect to
是在 2011 年的 Sinatra 1.2 中引入的。如果你没有这个,你的 Heroku 服务器上一定是 运行 一个非常旧的 Sinatra 版本。
采取 look here for getting started with Heroku,并确保您的 Gemfile 具有 Sinatra 1。4.x(在回答此问题时最新)指定:
gem 'sinatra', '~>1.4.0'