我遇到的问题:ExecJS :: RuntimeError在聊天室#显示
这是我room.coffee文件,一切正常。
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;
}
}
<h1><%= @chat_room.title %></h1>
<div id="messages" data-chat-room-id="<%= @chat_room.id %>">
<%= render @chat_room.messages %>
</div>
<hr>
<%= form_for @message, url: '#' do |f| %>
<%= hidden_field_tag 'chat_room_id', @chat_room.id %>
<div class="form-group">
<%= f.label :body %>
<%= f.text_area :body, class: 'form-control' %>
<small class="text-muted">From 2 to 1000 characters</small>
</div>
<%= f.submit "Post", class: 'btn btn-primary btn-lg' %>
<% end %>
但它显示ExecJS :: RuntimeError后,我在同一个文件添加的代码下面下来。
$('#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
我做搜索类似的问题很多,谁使用PC大多数人遇到过这个问题。但我正在使用mac,我不知道为什么我也有这个错误。
http://stackoverflow.com/questions/8362458/error-when-running-rails-app-execjsruntimeerror – JGutierrezC