有人可以给我一些关于这个actioncable错误的指示吗?

时间:2017-02-07 17:27:33

标签: ruby-on-rails heroku redis sidekiq actioncable

您好,有人可以向我解释此错误。 它适用于本地机器,也可以在本地使用heroku时使用 因为它是在heroku生产上运行的,它给了我这个错误,我已经完成了所有的测试,并试图获得更多的错误数据,但没有运气。

有什么用途:heroku,sidekiq,actioncable,ruby on rails 5.0.1

[ActionCable] [test@mail.com] Could not execute command from {"command"=>"message", "identifier"=>"{\"channel\":\"RoomChannel\"}", "data"=>"\"message:message\""}) 
[NoMethodError - undefined method `except' >for "message: message":String
2017-02-06T00:48:33.207838+00:00 app[web.1]:
Did you >mean?  exec]:       /app/vendor/bundle/ruby/2.3.0/gems/actioncable->
5.0.1/lib/action_cable/channel/base.rb:272:in `block in   action_signature' 
| /app/vendor/bundle/ruby/2.3.0/gems/actioncable-  5.0.1/lib/action_cable/channel/base.rb:271:in `tap' 
| /app/vendor/bundle/ruby/2.3.0/gems/actioncable-  5.0.1/lib/action_cable/channel/base.rb:271:in `action_signature' 
|   /app/vendor/bundle/ruby/2.3.0/gems/actioncable-5.0.1/lib/action_cable/channel/base.rb:169:in   `perform_action' 
| /app/vendor/bundle/ruby/2.3.0/gems/actioncable-  5.0.1/lib/action_cable/connection/subscriptions.rb:53:in `perform_action'

room.coffe

App.room = App.cable.subscriptions.create "RoomChannel",
connected: ->
console.log "live"
# Called when the subscription is ready for use on the server

disconnected: ->
# Called when the subscription has been terminated by the server

received: (data) ->
console.log data
# Called when there's incoming data on the websocket for this channel
$messages = $('#messages')
$messages.append data
$messages.scrollTop $messages.prop('scrollHeight')

speak: (message) ->
console.log message
@perform 'speak', message: message

room_channel.rb

class RoomChannel < ApplicationCable::Channel
 def subscribed
  stream_from "room_channel"
 end

 def unsubscribed
 # Any cleanup needed when channel is unsubscribed
 end

 def speak(data)
  Message.create! content: data['message'], user: current_user
  end
 end

BroadcastMessageJob.rb

class BroadcastMessageJob < ApplicationJob
queue_as :default

def perform(message)
 ActionCable.server.broadcast 'room_channel', render_message(message)
end

private
def render_message(message)
 ApplicationController.renderer.render message
 end
end

model message.rb

 class Message < ApplicationRecord
 belongs_to :user
 after_create_commit { BroadcastMessageJob.perform_later self }

提前谢谢。

0 个答案:

没有答案