I’m getting ExecJS::RuntimeError when i try to start Rails server and the server log gives me the following:
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>
I found that this error happens because Ubuntu don’t have a javascript runtime installed.
Okay. I’ve installed nodejs v0.6.3 from sources and tried to add gem 'therubyracer' to my Gemfile as it was suggested but the error still apperars.
What have i missed? Thanks in advance.
My items.js.coffee looks like this:
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')
You have this in your CoffeeScript:
And the error say this:
If you backtrack through your CoffeeScript from that
delete marker, you’ll see thatmarkeris an argument and you can’t use the JavaScriptdeleteoperator on an argument.You should be able to get rid of that
delete markerwithout causing problems, just themarker.setMap(null)should be enough to make it go away.