While working through driftingruby's interactive calendar tutorial, I've encountered an issue.
Everything with the calendar seems to be working fine, but when I try to drag and input an event date range, nothing is happening. Can anyone provide some guidance on this problem?
I suspect that the problem lies within my JavaScript files. Here's the code:
//daterangepicker.js
var date_range_picker;
date_range_picker = function() {
$('.date-range-picker').each(function(){
$(this).daterangepicker({
timePicker: true,
timePickerIncrement: 30,
alwaysShowCalendars: true
}, function(start, end, label) {
$('.start_hidden').val(start.format('YYYY-MM-DD HH:mm'));
$('.end_hidden').val(end.format('YYYY-MM-DD HH:mm'));
});
})
};
$(document).on('turbolinks:load', date_range_picker);
//fullcalendar.js
var initialize_calendar;
initialize_calendar = function() {
$('.calendar').each(function(){
var calendar = $(this);
calendar.fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
selectable: true,
selectHelper: true,
editable: true,
entryLimit: true,
entrys: '/entrys.json',
select: function(start, end) {
$.getScript('/entrys/new', function() {
$('#entry_date_range').val(moment(start).format("MM/DD/YYYY HH:mm") + ' - ' + moment(end).format("MM/DD/YYYY HH:mm"))
date_range_picker();
$('.start_hidden').val(moment(start).format('YYYY-MM-DD HH:mm'));
$('.end_hidden').val(moment(end).format('YYYY-MM-DD HH:mm'));
});
calendar.fullCalendar('unselect');
},
entryDrop: function(entry, delta, revertFunc) {
entry_data = {
entry: {
id: entry.id,
start: entry.start.format(),
end: entry.end.format()
}
};
$.ajax({
url: entry.update_url,
data: entry_data,
type: 'PATCH'
});
},
entryClick: function(entry, jsEvent, view) {
$.getScript(entry.edit_url, function() {
$('#entry_date_range').val(moment(entry.start).format("MM/DD/YYYY HH:mm") + ' - ' + moment(entry.end).format("MM/DD/YYYY HH:mm"))
date_range_picker();
$('.start_hidden').val(moment(entry.start).format('YYYY-MM-DD HH:mm'));
$('.end_hidden').val(moment(entry.end).format('YYYY-MM-DD HH:mm'));
});
}
});
})
};
$(document).on('turbolinks:load', initialize_calendar);
//create.js.erb
$('.calendar').fullCalendar(
'renderEntry',
$.parseJSON("<%=j render(@entry, format: :json).html_safe %>"),
true
);
$('.modal').modal('hide');
Thank you in advance for any help.
EDIT
Log
Started GET "/entries/new?_=1490713885661" for ::1 at 2017-03-28 17:06:42 +0100
Processing by EntriesController#new as JS
Parameters: {"_"=>"1490713885661"}
Rendered entries/_form.html.erb (79.1ms)
Rendered entries/_new.html.erb (116.2ms)
Rendered entries/new.js.erb (152.2ms)
Completed 500 Internal Server Error in 207ms (ActiveRecord: 0.0ms)
ActionView::Template::Error (undefined method `entries_index_path' for #<#<Class:0xa441290>:0xb949cc0>):
1: <%= simple_form_for @entry, remote: true do |f| %>
2: <div class="form-inputs">
3: <%= f.input :title %>
4: <%= f.input :date_range, input_html: { class: "form-control input-sm date-range-picker" } %>
app/views/entries/_form.html.erb:1:in `_app_views_entries__form_html_erb__139031211_82152084'
app/views/entries/_new.html.erb:9:in `_app_views_entries__new_html_erb__484549457_82186272'
app/views/entries/new.js.erb:1:in `_app_views_entries_new_js_erb___326163301_82413240'
Rendered [...]