Javascript 如何修复此错误:获取操作中的错误cable rails 5
我在Javascript 如何修复此错误:获取操作中的错误cable rails 5,javascript,ruby-on-rails,coffeescript,ruby-on-rails-5,actioncable,Javascript,Ruby On Rails,Coffeescript,Ruby On Rails 5,Actioncable,我在game.coffe这个文件中写了下面的代码 App.game = App.cable.subscriptions.create "GameChannel", connected: -> ... disconnected: -> ... received: (data) -> switch data.action when "game_start" $('#status').html("Player found"
game.coffe
这个文件中写了下面的代码
App.game = App.cable.subscriptions.create "GameChannel",
connected: ->
...
disconnected: ->
...
received: (data) ->
switch data.action
when "game_start"
$('#status').html("Player found")
App.gamePlay = new Game('#game-container', data.msg)
when "take_turn"
App.gamePlay.move data.move
App.gamePlay.getTurn()
when "new_game"
App.gamePlay.newGame()
when "opponent_withdraw"
$('#status').html("Opponent withdraw, You win!")
$('#new-match').removeClass('hidden');
take_turn: (move) ->
@perform 'take_turn', data: move
new_game: () ->
@perform 'new_game'
当我在浏览器中运行此代码时,它会像这样显示错误
game.self-9aed049….js?body=1:42 Uncaught ReferenceError: Game is not defined
在浏览器控制台中。游戏应该来自哪里?你是如何安排
Game
成为全球游戏的?@muistooshort我是从Github做的,但我发现错误博客文章中的代码不完整,显然你需要从Github获取全部内容。@muistooshort我是从Github做的。我还是会出错。