У меня возникла проблема с запуском ActionCable на моей машине.ТипError: App.cable не определено
В активах/JavaScripts/каналов У меня есть два файла:
index.coffee
#= require action_cable
#= require_self
#= require_tree .
@App = {}
App.cable = ActionCable.createConsumer()
и question.coffee
App.question = App.cable.subscriptions.create "QuestionChannel",
connected: ->
# Called when the subscription is ready for use on the server
disconnected: ->
# Called when the subscription has been terminated by the server
received: (data) ->
# Called when there's incoming data on the websocket for this channel
follow: ->
@perform 'follow'
unfollow: ->
@perform 'unfollow'
мой application.js файл выглядит следующим образом:
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets
//= require icheck
//= require homer/scripts
//= require Chart
//= require excanvas
//= require channels
//= require_tree .
Когда я начинаю кабельный сервер и сервер рельсов и посетить Localhost: 3000 в FireFox консоли я вижу две ошибки:
SyntaxError: An invalid or illegal string was specified
this.webSocket = new WebSocket(this.consumer.url);
и
TypeError: App.cable is undefined
App.question = App.cable.subscriptions.create("QuestionChannel", {
Я использую рельсы 5 Beta 3. Как я могу исправить это?
Так что 'ActionCable.createConsumer()' должен возвращаться не определен. – epascarello
Когда я набираю консоль firefox '' 'ActionCable.createConsumer()' '', он возвращает '' 'SyntaxError: указана недопустимая или недопустимая строка this.webSocket = новый WebSocket (this.consumer.url);' '' –
Итак, какова ценность 'this.consumer.url'? – epascarello