0
チャットアプリケーションで画像を添付します。私はテキストチャットでやったが、私はactioncableで添付ファイルを送信することができません。ActionCable with attachment
App.global_chat = App.cable.subscriptions.create {
channel: "ChatRoomsChannel"
chat_room_id: messages.data('chat-room-id')
},
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) ->
messages.append data['message']
messages.append data['attachment']
messages_to_bottom()
send_message: (message, chat_room_id, attachment) ->
@perform 'send_message', message: message, chat_room_id: chat_room_id, attachment: attachment
$('#new_message').submit (e) ->
$this = $(this)
textarea = $this.find('#message_body')
attachment = $this.find('#message_attachment')
if $.trim(textarea.val()).length > 1
App.global_chat.send_message textarea.val(), messages.data('chat-room-id'), attachment[0].files[0]
textarea.val('')
attachment.val('')
e.preventDefault()
return false