为什么我的日历无法在索引页中查看:ruby rails
Why does my calendar not viewed in index page: ruby on rails
您好,我试图在我的 rails 测试项目中实现日历。所以我在项目中使用了 'fullCalendar' gem 。由于我是 rails 的新手,所以我按照下面的 link 来了解如何使用日历。现在我的问题是无法在我的 rails 应用程序中获取日历。不知道我犯了什么错误。如果有人知道,请告诉我。我还在 application.js 和 application.css.css 中添加了 fullCalendar js。我也是 jquery 的新手。然后没跟完link。在中间挣扎。提前致谢
Link
http://blog.crowdint.com/2014/02/18/fancy-calendars-for-your-web-application-with-fullcalendar.html
这是我的索引页
<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 %>
<div id="calendar"></div>
<script>
$('#calendar').fullCalendar();
</script>
这是我的application.js
// 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 any plugin's vendor/assets/javascripts directory 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 .
这是application.css.css
/*
* 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 any plugin's vendor/assets/stylesheets directory 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 bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*= require fullcalendar
*/
编辑
我在 Mr.Tien 的帮助下找到了解决方案。谢谢您的帮助。实际上问题是 gem 文件。 gem 可能已损坏。这就是calnedar没有来的原因。现在我找到了另一个解决方案。我已经在布局中发布了我的 application.html.erb。这可能对某人有用。
回答
<head>
<title>CalendarApp</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'https://raw.githubusercontent.com/bokmann/fullcalendar-rails/master/vendor/assets/javascripts/fullcalendar.js' %>
<%= javascript_include_tag 'http://momentjs.com/downloads/moment-with-locales.js' %>
<%= csrf
_meta_tags %>
</head>
查看fullCalendar和moment的url。如前所述,复制 link 并将其粘贴到 application.html.erb 中。问题已解决
尝试包装你的函数
$('#calendar').fullCalendar()
在jquery就绪函数
$(function() { $('#calendar').fullCalendar(); })
关于就绪功能,您可以在那里阅读 http://api.jquery.com/ready/
你把 fullcalendar.css
和 .js
放在哪里了?您还可以使用另一个完整日历 gem - 我建议您将 gem 'fullcalendar_engine'
添加到您的 Gemfile,运行 bundle install
和 bundle exec rails g fullcalendar_engine:install
。还要确保修改你的 application.js
:
//= require fullcalendar_engine/application
和你的 application.css
:
*= require fullcalendar_engine/application
那就是我会做的。您会在 https://github.com/vinsol/fullcalendar-rails-engine
上找到文档
您好,我试图在我的 rails 测试项目中实现日历。所以我在项目中使用了 'fullCalendar' gem 。由于我是 rails 的新手,所以我按照下面的 link 来了解如何使用日历。现在我的问题是无法在我的 rails 应用程序中获取日历。不知道我犯了什么错误。如果有人知道,请告诉我。我还在 application.js 和 application.css.css 中添加了 fullCalendar js。我也是 jquery 的新手。然后没跟完link。在中间挣扎。提前致谢
Link
http://blog.crowdint.com/2014/02/18/fancy-calendars-for-your-web-application-with-fullcalendar.html
这是我的索引页
<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 %>
<div id="calendar"></div>
<script>
$('#calendar').fullCalendar();
</script>
这是我的application.js
// 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 any plugin's vendor/assets/javascripts directory 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 .
这是application.css.css
/*
* 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 any plugin's vendor/assets/stylesheets directory 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 bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*= require fullcalendar
*/
编辑
我在 Mr.Tien 的帮助下找到了解决方案。谢谢您的帮助。实际上问题是 gem 文件。 gem 可能已损坏。这就是calnedar没有来的原因。现在我找到了另一个解决方案。我已经在布局中发布了我的 application.html.erb。这可能对某人有用。
回答
<head>
<title>CalendarApp</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'https://raw.githubusercontent.com/bokmann/fullcalendar-rails/master/vendor/assets/javascripts/fullcalendar.js' %>
<%= javascript_include_tag 'http://momentjs.com/downloads/moment-with-locales.js' %>
<%= csrf
_meta_tags %>
</head>
查看fullCalendar和moment的url。如前所述,复制 link 并将其粘贴到 application.html.erb 中。问题已解决
尝试包装你的函数
$('#calendar').fullCalendar()
在jquery就绪函数
$(function() { $('#calendar').fullCalendar(); })
关于就绪功能,您可以在那里阅读 http://api.jquery.com/ready/
你把 fullcalendar.css
和 .js
放在哪里了?您还可以使用另一个完整日历 gem - 我建议您将 gem 'fullcalendar_engine'
添加到您的 Gemfile,运行 bundle install
和 bundle exec rails g fullcalendar_engine:install
。还要确保修改你的 application.js
:
//= require fullcalendar_engine/application
和你的 application.css
:
*= require fullcalendar_engine/application
那就是我会做的。您会在 https://github.com/vinsol/fullcalendar-rails-engine
上找到文档