Rails css资产管道没有拉入其他样式表。

时间:2016-10-27 22:41:44

标签: css ruby-on-rails twitter-bootstrap asset-pipeline

所以我正在构建一个应用程序&我添加了bootstrap-sass宝石。这是我的gemfile的样子:

gem 'rails', '4.2.6'
gem 'bootstrap-sass'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'bcrypt', '~> 3.1.7'

group :development, :test do
  gem 'byebug'
  gem 'sqlite3',  '1.3.11'
end

group :development do
  gem 'web-console', '~> 2.0'
  gem 'spring'
end

group :production do
    gem 'pg'
end

我的路线文件夹:

Rails.application.routes.draw do
  root 'landing_page#home'
  get 'users/new'
end

我有两个样式表application.scss& landing_page.scss

我只想尝试设置我的目标网页。但是,我无法从landing_page.scss加载任何样式。如果放在application.scss中,我只能加载这些样式。

以下是application.scss

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


@mixin box_sizing {
  -moz-box-sizing:    border-box;
  -webkit-box-sizing: border-box;
  box-sizing:         border-box;
}

.debug_dump {
  clear: both;
  float: left;
  width: 100%;
  margin-top: 45px;
  @include box_sizing;
}

body{
  background-color: #525252;
}

任何人都知道我做错了什么?放置在landing_page.scss时,为什么没有应用sass或只是普通的CSS?

1 个答案:

答案 0 :(得分:2)

您希望@import偏向sass文件。请参阅http://sass-lang.com/guide以了解部分工作原理。

在您的情况下,您应该将landing_page.scss重命名为_landing_page.scss并在@import landing_page文件中执行application.scss