当我尝试启动Rails服务器时,我得到ExecJS::RuntimeError
,服务器日志给出了以下内容:
ActionView::Template::Error (delete operand may not be argument or var
(in /home/sergey/Perfecto/arena/app/assets/javascripts/items.js.coffee)):
47: <%= raw flash_messages %>
48: </div>
49:
50: <%= javascript_include_tag "application" %>
51: <%= yield :javascripts %>
52: <%= yield :scripts %>
53: </body>
我发现发生此错误是因为Ubuntu没有安装javascript运行时。
好的。我已经从源代码安装了nodejs v0.6.3
,并尝试按照建议添加gem 'therubyracer'
Gemfile
,但错误仍然存在。
我错过了什么?提前谢谢。
我的items.js.coffee
看起来像这样:
jQuery ->
if $('#main.items_controller.new').length > 0
overlay = null
iconOffsetX = 26
iconOffsetY = 52
disableDraggingFor = (el) ->
el.draggable = false
el.onmousedown = (event) ->
event.preventDefault()
return false
$(".draggable_item, #new_items_queue").disableSelection()
$.each $(".draggable_item"), (i, el) ->
disableDraggingFor(el)
showInfobox = (marker,data) ->
boxText = document.createElement("div")
boxText.style.cssText = "height: 100%; background: url('/images/form.png') no-repeat;"
boxText.innerHTML = '<div id="infoboxContent">' + data + '</div>'
myOptions =
content: boxText
disableAutoPan: false
maxWidth: 0
pixelOffset: new google.maps.Size(-79, -386)
zIndex: 0
boxStyle:
width: "650px"
height: "350px"
closeBoxMargin: "10px"
infoBoxClearance: new google.maps.Size(1, 1)
isHidden: false
pane: "floatPane"
enableEventPropagation: false
ib = new InfoBox(myOptions)
oldDraw = ib.draw
ib.draw = ->
oldDraw.apply(@)
jQuery(ib.div_).hide()
jQuery(ib.div_).fadeIn(900)
$("#item_name").focus()
priceResult = $("#converted_price")
$("#item_price").live "keydown keyup keypress focus blur paste change", ->
fx.base = "USD"
fx.rates =
"KGS": 46.4
input = accounting.unformat $("#item_price").val()
result = accounting.formatMoney fx.convert(input, from: "USD", to: "KGS"),
symbol: "сом"
precision: 0
thousand: " "
format:
pos : "%v %s"
neg : "(%v) %s"
zero: "0 %s"
priceResult.html result
ib.open(Gmaps.map.map, marker)
google.maps.event.addListener marker, 'dragstart', ->
ib.hide()
google.maps.event.addListener marker, 'dragend', ->
newPosition = @getPosition()
$.ajax "/items/reverse_geocode",
type: 'GET'
dataType: 'text'
data:
lat: newPosition.lat()
lng: newPosition.lng()
error: (jqXHR, textStatus, errorThrown) ->
console.log "AJAX Error: #{textStatus}"
success: (data, textStatus, jqXHR) ->
$("#item_location").val data
ib.show()
$('#item_latitude').val newPosition.lat()
$('#item_longitude').val newPosition.lng()
google.maps.event.addListener ib, 'domready', ->
$('#change_position').bind 'click', ->
ib.close()
marker.setAnimation google.maps.Animation.BOUNCE
google.maps.event.addListener marker, 'position_changed', ->
setTimeout (->
ib.open(Gmaps.map.map, marker)
), 300
google.maps.event.addListener ib, 'closeclick', ->
marker.setMap(null)
delete marker
$(".draggable_item").draggable("enable")
placeMarker = (location,icon,shadow,kind) ->
$.ajax "/items/reverse_geocode",
type: 'GET'
dataType: 'text'
data:
lat: location.lat()
lng: location.lng()
onlyCountry: true
error: (jqXHR, textStatus, errorThrown) ->
console.log "AJAX Error: #{textStatus}"
success: (data, textStatus, jqXHR) ->
if data != "Киргизия"
humane "Вы можете добавлять объявления только в Кыргызстане"
else
$(".draggable_item").draggable("disable")
marker = new google.maps.Marker
position: location
map: Gmaps.map.map
icon: icon
shadow: shadow
draggable: true
zIndex: 99
$.ajax "/items/new.js",
type: 'GET'
dataType: 'text'
data:
content: kind
lat: location.lat()
lng: location.lng()
error: (jqXHR, textStatus, errorThrown) ->
console.log "AJAX Error: #{textStatus}"
success: (data, textStatus, jqXHR) ->
showInfobox marker, data
Gmaps.map.callback = ->
@.map.mapTypes.set "OSM", new google.maps.ImageMapType(
getTileUrl: (coord, zoom) ->
"http://192.168.0.112/osm_tiles2/" + zoom + "/" + coord.x + "/" + coord.y + ".png"
tileSize: new google.maps.Size(256, 256)
name: "OpenStreetMap"
maxZoom: 18
)
@.map.setMapTypeId("OSM")
overlay = new google.maps.OverlayView()
overlay.draw = ->
overlay.setMap @.map
$.each $(".draggable_item"), ->
$(@).draggable
cursor: "move",
revert: false,
helper: 'clone',
stop: (event,ui) ->
point = new google.maps.Point ui.offset.left+iconOffsetX,ui.offset.top+iconOffsetY
location = overlay.getProjection().fromContainerPixelToLatLng(point)
placeMarker location, $(@).data('marker'), $(@).data('shadow'), $(@).data('kind')
答案 0 :(得分:4)
你在CoffeeScript中有这个:
google.maps.event.addListener ib, 'closeclick', ->
marker.setMap(null)
delete marker
$(".draggable_item").draggable("enable")
错误说:
删除操作数可能不是参数或var
如果您从delete marker
回溯了CoffeeScript,您会看到marker
是一个参数,您不能在参数上使用JavaScript delete
运算符。
你应该能够摆脱delete marker
而不会造成问题,只有marker.setMap(null)
应该足以让它消失。
答案 1 :(得分:0)
尝试在Gemfile中添加gem“execjs”,“〜&gt; 1.3.0”。 我想它可以解决这个问题......
答案 2 :(得分:0)
较旧的线程但我也遇到了同样的问题但是通过简单地重命名我的javascript并删除所有文件名末尾的'.coffee'来解决它。
例如:
自:
'name'.js.coffee
为:
'name'.js
由于某种原因,这有效。