Question

i'm working through this example:

http://road2ruby.blogspot.com/2013/01/jquery-full-calendar-with-rails3.html

and when I run my server and try to go to the /events url, I get the following error:

ExecJS::RuntimeError at /events
SyntaxError: unexpected COMPARE
  (in /Users/rabdelaz/swap/app/assets/javascripts/calendar.js.coffee)

The error is pointing to this line of my application.js:

<%= javascript_include_tag "application", "data-turbolinks-track" => true %>

Here's my whole application.js

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><%= content_for?(:title) ? yield(:title) : "Swap" %></title>
    <meta name="description" content="<%= content_for?(:description) ? yield(:description) : "Swap" %>">
    <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
    <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
    <%= csrf_meta_tags %>
  </head>
  <body>
    <header>
      <%= render 'layouts/navigation' %>
    </header>
    <main role="main">
       <%= render 'layouts/messages' %>
       <%= yield %>
    </main>
  </body>
</html>

I'm not sure exactly what this error means or why I'm getting it. I'm very new to javascript and coffeescript.

$(document).ready ->  
  $('#calendar').fullCalendar  
   editable: true,  
   header:  
    left: 'prev,next today',  
    center: 'title',  
    right: 'month,agendaWeek,agendaDay'  
   defaultView: 'month',  
   height: 500,  
   slotMinutes: 30,  
   eventSources: [{  
    url: '/events',  
   }],  
   timeFormat: 'h:mm t{ - h:mm t} ',  
   dragOpacity: "0.5"  
   eventDrop: (event, dayDelta, minuteDelta, allDay, revertFunc) ->  
    updateEvent(event);  
   eventResize: (event, dayDelta, minuteDelta, revertFunc) ->  
    updateEvent(event);  
  <br/>  
 updateEvent = (the_event) ->  
  $.update "/events/" + the_event.id,  
   event:  
    title: the_event.title,  
    starts_at: "" + the_event.start,  
    ends_at: "" + the_event.end,  
    description: the_event.description      
Was it helpful?

Solution

There's some formatting you accidentally picked up from the tutorial - on line 20, there's a <br> tag, which isn't valid CoffeeScript. Removing it should do the trick.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top