ExecJS :: RuntimeError in ChatRooms # show

综合技术 2018-06-23

The issue I'm having:

This is my room.coffee file, and everything works well.

jQuery(document).on 'turbolinks:load', ->
  messages = $('#messages')
  if $('#messages').length > 0

    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) ->
        # Data received

      send_message: (message, chat_room_id) ->
        @perform 'send_message', message: message, chat_room_id: chat_room_id
@import "bootstrap-sprockets";
@import "bootstrap";

#messages {
  max-height: 450px;
  overflow-y: auto;
  .avatar {
    margin: 0.5rem;
  }
}

<div id="messages" data-chat-room-id="">

From 2 to 1000 characters

But it shows ExecJS::RuntimeError after I added the code down below in the same file.

$('#new_message').submit (e) ->
      $this = $(this)
      textarea = $this.find('#message_body')
      if $.trim(textarea.val()).length > 1
        App.global_chat.send_message textarea.val(), messages.data('chat-room-id')
        textarea.val('')
      e.preventDefault()
      return false

I did search similar problems a lot, and most people who use pc encountered this issue. But I'm using mac, I have no idea why I got this error as well.

You need javascript runtime environment

Install node.js or add therubyracer gem

sudo apt-get install nodejs

ORAdd therubyracer gem in your Gemfile

gem 'therubyracer'
Hello, buddy!

责编内容by:Hello, buddy! (源链)。感谢您的支持!

您可能感兴趣的

Hello World App In Node.js NodeJS NodeJS is a lean, fast, cross-platform Javascript runtime environme...
Node.js + Socket IO + Apache + PHP remove port fro... I have a few questions regarding using socket IO with PHP and such, I am new to ...
NodeJS + Socket.io connections dropping/reconnecti... In production, I have a game which uses connection-local variables to hold game ...
超简单的前端跨域、前后端分离解决方案... LiveNode是一个基于Node.js轻巧的web服务,帮助前端开发者解决本地跨域,代码刷新,以及SPA(单页应用)前后端服务分离,并且可以用于生产环境...
Learn to build an Amazon Alexa Skill with Node.js ... Learn to build an Amazon Alexa Skill with Node.js (and get pai...