简体   繁体   English

在Ruby on Rails中将Fullcalendar与Twitter Bootstrap结合使用

[英]Using Fullcalendar with Twitter Bootstrap in Ruby on Rails

I'm very much a novice in the Ruby on Rails world. 我是Ruby on Rails世界的新手。 As a small exercise, I'm attempting to set up a basic (but polished) calendar with tagging capabilities. 作为一个小练习,我试图设置一个具有标记功能的基本(但精致)日历。 Fullcalendar is working very nicely for the calendar and acts-as-taggable-on is a nice tagging system. Fullcalendar在日历上工作得非常好,并且可标记行为是一个很好的标记系统。

Where I'm running into trouble, however, is with using Twitter Bootstrap for nice buttons and layouts. 但是,我遇到麻烦的地方是使用Twitter Bootstrap获得漂亮的按钮和布局。 I can't seem to get the gem to actually do anything; 我似乎无法让宝石真正地做任何事。 my pages look completely unchanged after installing it following Railscast #328 ( http://railscasts.com/episodes/328-twitter-bootstrap-basics ). 按照Railscast#328( http://railscasts.com/episodes/328-twitter-bootstrap-basics )安装后,我的页面看起来完全没有变化。

Right now, my application.html.erb looks like this: 现在,我的application.html.erb看起来像这样:

  1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html>
  2 <head>
  3   <title>Calendar</title>
  4   <%= stylesheet_link_tag "fullcalendar.css" %>
  5   <%= stylesheet_link_tag "bootstrap-fullcalender.css" %>
  6   <%= stylesheet_link_tag "application.css" %>
  7   <%= javascript_include_tag "jquery.js" %>
  8   <%= javascript_include_tag "jquery.rest.js" %>
  9   <%= javascript_include_tag "rails.js" %>
 10   <%= javascript_include_tag "application.js" %>
 11 
 12   <!-- these are needed for the calendar. -->
 13   <%= javascript_include_tag "jquery-ui-1.8.11.custom.min.js" %>
 14   <%= javascript_include_tag "fullcalendar.js" %>
 15   <%= javascript_include_tag "calendar.js" %>
 16 
 17   <%= csrf_meta_tag %>
 18 
 19   <%= javascript_tag "var AUTH_TOKEN = #{form_authenticity_token.inspect};" if protect_against_forgery? %>
 20 
 21 </head>
 22 <body>
 23 
 24 <%= yield %>
 25 
 26 </body>
 27 </html>


The bootstrap-fullcalendar.css file was shamelessly "borrowed" from brennovich's solution at https://github.com/addyosmani/jquery-ui-bootstrap/issues/37 . bootstrap-fullcalendar.css文件是从brennovich的解决方案“ https://github.com/addyosmani/jquery-ui-bootstrap/issues/37 ”中无耻地“借用”的。 I placed the file in both /app/assets/stylesheets and /public/stylesheets but have had no luck with it. 我将文件放在/ app / assets / stylesheets和/ public / stylesheets中,但是运气不好。



Any suggestions as to how to get this working and/or an alternative to Bootstrap for nice formatting? 关于如何使其正常工作和/或替代Bootstrap进行格式化的任何建议?

EDIT: 编辑:

Gemfile, application.css, and application.js are posted in one of the comments below (I only have a limited number of links, sadly :-/) Gemfile,application.css和application.js在以下评论之一中发布(可悲的是,我只有有限数量的链接:-/)
Also noticed that I get an "ActionController::RoutingError (No route matches [GET] "/stylesheets/bootstrap-fullcalender.css"):" error while starting the server...that seems important. 还注意到我在启动服务器时收到“ ActionController :: RoutingError(没有路由与[GET]“ / stylesheets / bootstrap-fullcalender.css”匹配):“错误...这似乎很重要。

Ok, so if you are sure the file is on app/assets/bootstrap-fullcalender.css, then you don't need it on /public/stylesheets, remove it from /public/stylesheets (its gonna be precompile by rails so not worries about that). 好的,因此,如果您确定文件位于app / assets / bootstrap-fullcalender.css上,则无需在/ public / stylesheets上使用该文件,请将其从/ public / stylesheets中删除(该文件可以通过Rails进行预编译,因此无需对此感到担忧)。

Then restart your server, and this url should give you the stylesheet: 然后重新启动服务器,该URL应该为您提供样式表:

http://localhost:3000/assets/bootstrap-fullcalender.css

Check that and we can continue from there 检查一下,我们可以从那里继续

Since someone upvoted this I decided to look back on what I did to fix this, since I did get this resolved eventually. 由于有人对此表示支持,所以我决定回顾一下为解决此问题所做的工作,因为最终我确实解决了该问题。 It appears all I did was change the line in my gemfile to install from latest build, as per the instructions on the gem's github page: 看来我所做的就是按照gem的github页面上的说明更改gemfile中的行以从最新版本进行安装:

gem "twitter-bootstrap-rails", :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'

After that, it basically worked right out of the box. 之后,它基本上可以立即使用。 I was also able to later add on a bootstrap datetimepicker and colorpicker without much difficulty. 我以后也可以轻松添加bootstrap datetimepicker和colorpicker。 Go figure. 去搞清楚。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM