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!阅读原文】。感谢您的支持!

您可能感兴趣的

Remote node.js http server doesnt start or fails t... I ran some node.js tests on my windows machine and everything worked well. Now I installed node on my debian remote machine, and Im trying to ru...
Synchronized-C Return Goal return goal hash iteration value In Ruby, if we have a hash called my_hash and we decide to puts the key and valu...
Node.js and Socket.io – how far can they go ... I am going to build a web application to manage notes (think of something similar to Evernote). I have decided to use Backbone.js+JQuery client side....
10分钟学会用Nodejs开发Web服务器 这个教程能让您在短短10分钟之内,从对nodejs一点基础也没有到能用nodejs开发一个最简单的Web服务器。这个教程是在Windows 10操作系统里写的。 1. 登录网站https://nodejs.org/en/,下载nodejs安装文件。 双击进行安装,这个安装...
Async collection methods in Node.js Is there some framework similar to underscore that allows me to run async methods on collections. Something like _.each(collection, itemCa...