【问题标题】:Trouble installing bootstrap-sass 3.2 on a rails 4.1.0在 rails 4.1.0 上安装 bootstrap-sass 3.2 时遇到问题
【发布时间】:2014-10-22 13:58:03
【问题描述】:

我正在尝试安装 bootstrap-sass gem。我使用 RubyMine 作为 IDE 和 rails 4.1.0。我的 gem 文件如下所示:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.0'


gem 'sprockets', '2.11.0'

gem 'autoprefixer-rails'
gem 'sass-rails'
gem 'bootstrap-sass','3.2.0'


gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'haml'

gem 'sdoc', '~> 0.4.0',          group: :doc

group :development do
  gem 'spring'
  gem 'sqlite3'
  gem 'byebug',      '3.4.0'
  gem 'web-console', '2.0.0.beta3'
end


group :production do
  gem 'pg', '0.17.1'
  gem 'rails_12factor', '0.0.2'
end

在我的application.css.scss 文件中添加以下行时,我收到一个缺少文件引用的错误:

@import "bootstrap";
@import "bootstrap-sprockets";

如果我更改为像 2.3.2 这样的早期版本的 bootstrap-sass,我可以让第一个 import 语句 (@import "bootstrap") 工作,但第二个仍然失败。同样,对于我的 application.js 文件,//= require bootstrap-sprockets 行会引发找不到文件的错误。我的 application.css.scss 是:

/*
 * 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 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
 */
@import "bootstrap";
@import "bootstrap-sprockets"; 

【问题讨论】:

    标签: ruby-on-rails-4 asset-pipeline rubymine bootstrap-sass


    【解决方案1】:

    我在 Rubymine 上遇到了同样的错误,但是该应用程序运行良好,并且在运行时没有抛出错误。显然是一个 Rubymine 错误

    更新 1:

    我快速浏览了 gem 源代码。它只是使用一些自定义asset_path 设置而不是默认值。所以Rubymine无法检测到主资产文件在哪里

    更新 2: sprockets 在 bootstrap 之前,请参阅 Github Readme 和 require_self 应该在 require_tree 之前(因为您首先要加载 bootsrap css 文件,然后是所有其他 css 文件)

    /*
    *= require_self
    *= require_tree .
    */
    
    
    @import "bootstrap-sprockets";
    @import "bootstrap";
    

    【讨论】:

    • 你使用的是哪个版本的 sass-rails 和 bootstrap-sass?
    • sass-rails-4.0.3 bootstrap-sass-3.2.0.2
    猜你喜欢
    • 2014-06-28
    • 1970-01-01
    • 2012-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多