I have a question I am building a calendar using fullcalendar-rails, and I have a small problem. I am using the eventsources function (url parameter), so the calendar knows where to retrieve the events to display. But my events resources are nested under my users resources. Therefore to access the events i need to follow this route -> 'users/:id/events'. So my question is how do i go about transfering these required parameters to the eventsources :url function ? Also, I just want to mention that i am using json so the calendar maybe able to display the events. Inside my json array I have a url parameter that contains the event's url is there a way for me to transfer that json.url ?
I apologize that I have not displayed any of my codes yet but I am currently at work now and i do not have access to it. As sooon as get access to a pc ill reedit it and display my code. Its been bugging me for so long so I thought that Id just ask first.
Thanks in advance.
calendar.js.coffee
$(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.json" <----This is the part that where the calendar reads the events from but i need it to be 'users/:id/events.json'
timeFormat: 'H(:mm) ',
dragOpacity: "0.5",
displayEventEnd:
month: true,
basicWeek: true
eventDrop: (event, dayDelta, minuteDelta, allDay, revertFunc) ->
updateEvent(event);
eventResize: (event, dayDelta, minuteDelta, revertFunc) ->
updateEvent(event);
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
routes.rb
Rails.application.routes.draw do
get 'staticpages/welcome'
get 'staticpages/about'
get 'staticpages/contact'
get 'calendar/index'
root 'staticpages#welcome'
devise_for :users
resources :users, :only => [:show] do
member do
resources :events, :as => :user_events
end
end
index.json.jbuilber
json.array!(@events) do |event|
json.extract! event, :id, :title, :description
json.start event.starts_at
json.end event.ends_at
json.allday event.all_day
json.url event_url(event, format: :html)
end