I have a rails app. I\'m trying to integrate the fullcalendar into my app. For testing I created manually an event which shows up in the calendar after sending over with as_
regarding "is this line ok" lines:
eventSources: [{ url: '/users/:user_id/events', }], // IS THIS LINE OKAY?
you are mixing up your js and ruby which is why it isn't working.
'/users/:user_id/events'
is not a route. '/users/12234/events
is a route. Your js does not understand what :user_id
is -> you have to actually put a real user id in there.
the one thing I notice is missing from your controller code is anywhere where you instantiate an actual user... do you have current_user
? (ie are you using devise for users to login?) if so then you could plausibly use this:
eventSources: [{ url: '/users/<%= current_user.id %>/events', }], // IS THIS LINE OKAY?
however - I notice that your js file is named "events.js" and is thus not ruby-related at all - in which case the above is also not going to work because there's no ruby in a plain js file.
You will need to set some kind of javascript environment variable in your erb template... that the javascript code can access.
this is getting iffy in my own knowledge but I'd say a horrible, nasty hack would be to do something like:
<script>
var user_id = <%= current_user.id %>
</script>
I DO NOT RECOMMEND that you actually do this... google a better way - there must be some tutorials on integrating devise into your js in rails. It's here just to show you how your js and ruby must interact in order for the information to be available to your js.