简体   繁体   English

使用现有的rails app添加twitter-bootstrap-rails

[英]Adding twitter-bootstrap-rails with an existing rails app

I am trying to use twitter-bootstrap-rails with an existing rails application and getting the following error when i refreshed the page. 我试图使用twitter-bootstrap-rails与现有的rails应用程序,并在刷新页面时收到以下错误。

no such file to load -- less (in /app/assets/stylesheets/bootstrap_and_overrides.css.less) 没有这样的文件加载 - 少(在/app/assets/stylesheets/bootstrap_and_overrides.css.less)

Extracted source (around line #5): 提取的来源(第5行):

2: <html>
3: <head>
4:   <title>Tracker</title>
5:   <%= stylesheet_link_tag    "application" %>
6:   <%= javascript_include_tag "application" %>
7:   <%= csrf_meta_tags %>
8: </head>

any idea what I am doing wrong? 知道我做错了什么吗? thanks 谢谢

In my case, only re-starting the rails server did not do the trick. 在我的情况下,只重新启动rails服务器没有做到这一点。 I had to do following things to fix the problem. 我必须做一些事情来解决这个问题。

1. I needed to install the missing gems first. 1.我需要先安装缺少的宝石。 I added following lines to my Gemfile : 我将以下行添加到我的Gemfile中:

  gem "therubyracer"
  gem "less-rails"

Then in console I ran: 然后在控制台中运行:

bundle install

2. Lastly, I had to re-start my rails server . 2.最后,我不得不重新启动我的Rails服务器

After all these steps, twitter bootstrap started working with my rails app. 完成所有这些步骤后,t​​witter bootstrap开始使用我的rails应用程序。 Hope this helps someone who faces the same trouble that I did ! 希望这可以帮助那些面临同样麻烦的人!

In some case, you have not installed therubyracer. 在某些情况下,您还没有安装therubyracer。

add

#gem 'therubyracer' , '= 0.10.2'

to your Gemfile and 到您的Gemfile和

#bundle install

may resolve this problem. 可以解决这个问题。 (In my case, I could not make the rubyracer 0.11.0, so I designated 0.10.2) (在我的情况下,我无法使rubyracer 0.11.0,所以我指定0.10.2)

If you have not installed libv8, you have to exec 如果你还没有安装libv8,你必须执行

#gem install libv8 --version=3.11.8.3

or something like this before hand. 或者像这样的事情。

I got it to work by replacing the stylesheet_link_tag to bootstrap_and_overrides. 我通过将stylesheet_link_tag替换为bootstrap_and_overrides来实现它。 However, I am using devise for authentication and twitter-bootstrap-rails, I think is messes up the devise user model because none of the logout or sign in functions work. 但是,我正在使用设计进行身份验证和twitter-bootstrap-rails,我认为这会破坏设计用户模型,因为没有注销或登录功能。

根据sdurg4的建议,我还可以通过在布局模板的stylesheet_link_tag标签中将'application'替换为'bootstrap_and_overrides'来实现此功能。

Using rails 3.2.13: 使用rails 3.2.13:

After I installed the 3 gems (therubyracer / less-rails / twitter-bootstrap-rails) I replaced this line *= require twitter/bootstrap with *= require bootstrap_and_overrides in application.css. 在我安装了3个宝石(therubyracer / less-rails / twitter-bootstrap-rails)后,我在application.css中替换了这行* = require twitter / bootstrap with * = require bootstrap_and_overrides。

From the github updating guide: 来自github更新指南:

This file imports Bootstrap and responsive styles for you (Responsive module is separated.) https://github.com/seyhunak/twitter-bootstrap-rails/wiki/Upgrading-Guide 此文件为您导入Bootstrap和响应式样式(响应模块是分开的。) https://github.com/seyhunak/twitter-bootstrap-rails/wiki/Upgrading-Guide

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

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