0
我正在嘗試在GoRails.com上的actioncable指南之後創建一個ActionCable聊天室。NoMethodError - 未定義的方法`safe_constantize'爲零:NilClass
由於我試圖連接到ActionCable我獲得以下錯誤: NoMethodError - 未定義的方法`safe_constantize」的零:NilClass
[ActionCable] [User 1] Could not execute command from
{"command"=>"subscribe", "identifier"=>"
{\"ChatroomsChannel\":\"ChatroomsChannel\",\"room_id\":1}"})
[NoMethodError - undefined method `safe_constantize' for
nil:NilClass]: /Users/Mathias/.rvm/gems/ruby-
[email protected]/gems/actioncable-
5.0.0.rc2/lib/action_cable/connection/subscriptions.rb:29:in `add' |
/Users/Mathias/.rvm/gems/[email protected]/gems/actioncable-
5.0.0.rc2/lib/action_cable/connection/subscriptions.rb:15:in
`execute_command' | /Users/Mathias/.rvm/gems/ruby-
[email protected]/gems/actioncable-
5.0.0.rc2/lib/action_cable/connection/base.rb:88:in
`dispatch_websocket_message' | /Users/Mathias/.rvm/gems/ruby-
[email protected]/gems/actioncable-
5.0.0.rc2/lib/action_cable/server/worker.rb:54:in `block in invoke' |
/Users/Mathias/.rvm/gems/[email protected]/gems/actioncable-
5.0.0.rc2/lib/action_cable/server/worker.rb:39:in `block in work'
我的應用程序/渠道/ chatrooms_channel.rb看起來是這樣的:
def subscribed
@chatroom = Chatroom.find(params[:room_id])
#puts params[:room_id]
#current_user.join_room(@chatroom)
stream_from "chatrooms:#{@chatroom.id}"
# stream_from "some_channel"
end
也許值得一提的是,我升級到從軌道4
軌5.0.0.rc2謝謝
不熟悉action_cable,但它似乎期望'channel'作爲頻道名稱的關鍵字,而不是'ChatroomsChannel'。 –