Я пытаюсь реализовать Example, но у меня возникают проблемы с самого начала. Я не вижу календарь на странице. Однако, когда я загружаю код с веб-страницы и делаю это, он работает.Rails Полный календарь не может быть показан
Так что я сделал это
- создать демонстрационную папку (рельсы нового демо)
- генерировать подмости (рельсы г эшафот название события: строковое описание: текст start_time: DATETIME END_TIME: DateTime)
- грабли БД: мигрировать
- Затем я добавил
gem 'fullcalendar-rails'
- пакет установки
- добавил JS и CSS
- добавил JS инициировать каландра
- положить Div тег в
index.html.erb
Так до сих пор я не могу увидеть календарь.
Адрес: gem file;
source 'https://rubygems.org'
gem 'rails', '4.2.1'
gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'fullcalendar-rails'
gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
gem 'byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
end
Вот index.html.erb
<p id="notice"><%= notice %></p>
<h1>Listing Events</h1>
<table>
<thead>
<tr>
<th>Title</th>
<th>Description</th>
<th>Start time</th>
<th>End time</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @events.each do |event| %>
<tr>
<td><%= event.title %></td>
<td><%= event.description %></td>
<td><%= event.start_time %></td>
<td><%= event.end_time %></td>
<td><%= link_to 'Show', event %></td>
<td><%= link_to 'Edit', edit_event_path(event) %></td>
<td><%= link_to 'Destroy', event, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= link_to 'New Event', new_event_path %>
<br>
<div id="calendar"></div>
Вот файл index.json.jbuilder
json.array!(@events) do |event|
json.extract! event, :id, :title, :description
json.start event.start_time
json.end event.end_time
json.url event_url(event, format: :html)
end
Вот это events.js.coffee
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
#
#
$(document).ready ->
$("#calendar").fullCalendar(
)
Вот приложения js и css файлы;
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require fullcalendar
//= require_tree .
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*= require fullcalendar
*/
Я не знаю, если это имеет значение, но когда я эшафот событий рельсы создали events.coffee папку, но я изменил его events.js.coffee как в примере. Все файлы js и css загружаются при загрузке индексной страницы, но не отображаются календари на странице
Возможный дубликат [Rails 4 с полным набором приложений init] (http://stackoverflow.com/questions/29912361/rails-4-with-fullcalendar-app-init) –
Но ответа нет? – Shalafister
проверьте свою консоль браузера, возможно, возникнет проблема с moment.js, если она не загружена, вы должны добавить ее с этим камнем [https://github.com/derekprior/momentjs-rails] –