title: How to properly use Fullcalendar jQuery plugin in rails
body: <p>I am using the gem 'fullcalendar-rails' in rails 4 to use the jquery fullcalendar, by the way I´m new in rails, and I've spent many days trying to make this work but I can't find a guide to do a proper post from the calendar to the controller in rails and then save it to the database.</p>
  
  <p>I've tried this guide, but nothing seems to work properly, does anyone know how to do this?</p>
  
  <p><a href="http://www.rkonrails.com/blog/2013/10/full-calendar-rails-jquery-full-calendar-in-rails/" rel="nofollow">http://www.rkonrails.com/blog/2013/10/full-calendar-rails-jquery-full-calendar-in-rails/</a></p>
  
  <p><a href="http://blog.crowdint.com/2014/02/18/fancy-calendars-for-your-web-application-with-fullcalendar.html" rel="nofollow">http://blog.crowdint.com/2014/02/18/fancy-calendars-for-your-web-application-with-fullcalendar.html</a></p>
  
  <p>Actually this is my code:</p>
  
  <p>EVENT MODEL</p>
  
  <pre><code>  class Event &lt; ActiveRecord::Base
      def self.between(start_time, end_time)
        where('starts_at &gt; :lo and starts_at &lt; :up',
          :lo =&gt; Event.format_date(start_time),
          :up =&gt; Event.format_date(end_time)
        )
      end
  
      def self.format_date(date_time)
       Time.at(date_time.to_i).to_formatted_s(:db)
      end
  
      def as_json(options = {})
        {
          :id =&gt; self.id,
          :title =&gt; self.title,
          :description =&gt; self.description || "",
          :start =&gt; starts_at.rfc822,
          :end =&gt; ends_at.rfc822,
          :allDay =&gt; self.all_day,
          :recurring =&gt; false,
          :url =&gt; Rails.application.routes.url_helpers.event_path(id)
        }
      end
    end
  </code></pre>
  
  <p>EVENT CONTROLLER</p>
  
  <pre><code>class EventsController &lt; ApplicationController
    def new
      @event = Event.new
      respond_to do |format|
        format.html # new.html.erb
        format.js
      end
    end
  
    def create
      @event = Event.new params['event']
  
      if @event.save
        render nothing: true
      else
        render :json =&gt; { }, :status =&gt; 500
      end
    end
  
    def index
      @events = Event.between(params['start'], params['end']) if (params['start'] &amp;&amp; params['end']) 
      respond_to do |format| 
        format.html # index.html.erb 
        format.json { render :json =&gt; @events } 
      end
    end
  end
  </code></pre>
  
  <p>CALENDAR.JS.COFFEE</p>
  
  <pre><code>$(document).ready -&gt; 
    $('#calendar').fullCalendar 
      editable: false,
  
      columnFormat: {
        month: 'dddd', 
        week: 'dddd d', 
        day: 'ddd' 
      }
      buttonText: {
        today:    'today',
        month:    'month',
        week:     'week',
        day:      'day'
      }
  
      minTime: "08:00:00"
      maxTime: "23:00:00"
      header:
        left: 'prev,next today', 
        center: 'title', 
        right: ''
      firstDay: 1
  
  
      selectable: true
      selectHelper: true
      select: (start, end) -&gt;
        title = prompt("Event Title:")
        eventData = undefined
        if title
          eventData =
            title: title
            start: start
            end: end
          $("#calendar").fullCalendar "renderEvent", eventData, true # stick? = true
        $("#calendar").fullCalendar "unselect"
  
  
      defaultView: 'agendaWeek',
      allDaySlot: false,
      height: 500, 
      slotMinutes: 30, 
      eventSources: [{ 
        url: '/events', 
      }], 
      timeFormat: 'h:mm t{ - h:mm t} ', 
      dragOpacity: "0.5" 
      eventDrop: (event, dayDelta, minuteDelta, allDay, revertFunc) -&gt; 
        updateEvent(event); 
      eventResize: (event, dayDelta, minuteDelta, revertFunc) -&gt; 
        updateEvent(event); 
  
  updateEvent = (the_event) -&gt; 
    $.update "/events/" + the_event.id, 
      event: 
        title: the_event.title, 
        starts_at: "" + the_event.start, 
        ends_at: "" + the_event.end, 
        description: the_event.description
  </code></pre>
  
  <p>EVENT MIGRATION</p>
  
  <pre><code>  create_table "events", force: true do |t|
      t.string   "title"
      t.string   "starts_at"
      t.string   "ends_at"
      t.string   "description"
      t.string   "allDay"
      t.datetime "created_at"
      t.datetime "updated_at"
    end
  </code></pre>