【问题标题】:Rails 3.2 bootstrap-sass not installingRails 3.2 bootstrap-sass 未安装
【发布时间】:2012-11-08 08:55:06
【问题描述】:

我正在尝试在我的 Rails 3.2 应用程序上安装 bootstrap-sass gem,但是当我调用 compass install bootstrap 时遇到此错误:

没有这样的框架:“bootstrap”

我的 Gemfile 中安装了 gem:

gem 'compass', '~> 0.12.2'
group :assets do
  ...
  gem 'sass-rails', '~> 3.2.4'
  gem 'compass-rails', '~> 1.0.3'
  gem 'bootstrap-sass', '~> 2.1.1.0'
end

我已将 import 语句放入我的 application.css.scss 文件中:

@import "bootstrap";

我的 application.js 中需要引导程序:

//= require jquery
//= require jquery_ujs
//= require bootstrap
...

我在我的 config.ru 文件中需要 bootstrap-sass:

require 'bootstrap-sass'

require ::File.expand_path('../config/environment',  __FILE__)

run MYAPP::Application

有人知道问题可能是什么,或者遇到了同样的问题吗?

这是 bootstrap-sass 的 git:https://github.com/thomas-mcdonald/bootstrap-sass.git

【问题讨论】:

    标签: ruby-on-rails twitter-bootstrap ruby-on-rails-3.2 sass bootstrap-sass


    【解决方案1】:

    bootstrap-sass 没有很好的文档记录,我需要一些时间来解决问题。 忘掉指南针吧。 宝石文件:

    gem 'bootstrap-sass', '~> 2.1.1.0'
    gem 'bootswatch-rails'
    

    使用 bootswatch-rails gem 可以快速改变你的主题

    在资产/样式表中,创建一个 your_own_sytlesheet.css.scss

        @import "bootswatch/cerulean/variables";
    
    // Then bootstrap itself
    @import "bootstrap";
    
    // Bootstrap body padding for fixed navbar
    body { padding-top: 60px; }
    
    // Responsive styles go here in case you want them
    @import "bootstrap-responsive";
    
    // And finally bootswatch style itself
    @import "bootswatch/cerulean/bootswatch";
    
    // Whatever application styles you have go last
    //@import "base";
    

    您可以通过将 cerulean 替换为其他名称来轻松更改主题。

    至少现在对我有用。

    【讨论】:

      【解决方案2】:

      想通了……

      所以要让安装工作,我不得不打电话给bundle exec compass install bootstrap。这会在包含所有 gem 的包的上下文中执行 compass install bootstrap。然而,这又引发了一些问题。

      安装将几个新的引导 javascript 文件写入我的 assets/javascripts 目录。在 Rails 3.2 中,这些是由资产管道自动加载的,但是顺序错误,所以在我的浏览器控制台中,我收到了缺少构造函数的错误消息,并在未定义的对象上调用了“popover”。经过一番挖掘,解决方案只是删除所有新生成的 javascript 文件,因为它们已经包含在 application.js 中的 //= require bootstrap 中。

      【讨论】:

        【解决方案3】:

        您不需要 gem。只需将引导库(scss 和 js 文件)复制到您的资产。 确保在 @import 'bootstrap' 之前的 application.css.scss 中没有更多文本; 并且不需要编辑 config.ru 文件

        还要查看您的页面代码。 application.css 中显示什么? 您是否在 ApplicationController 的控制器继承中使用了用户?

        【讨论】:

          【解决方案4】:

          在您的 gem 文件中,尝试将引导 gem 保留在资产之外。

          来源“https://rubygems.org”

          宝石'导轨','3.2.8'
          gem 'bootstrap-sass', '2.1.1'

          然后运行命令

          $ 捆绑安装。

          然后检查并确保使用命令安装了引导程序。

          $捆绑列表

          【讨论】:

          • 这看起来行不通。此外,它会在生产中包含 gem,这是我不想要的,因为我的资产将被预编译。
          猜你喜欢
          • 1970-01-01
          • 2013-12-26
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多