Nappstir
Nappstir

Reputation: 995

Rails css asset pipeline not pulling in other stylesheets.

So I am building an application & I have added the bootstrap-sass gem. Here is what my gemfile looks like:

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

I my routes folder:

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

And I have two stylesheets application.scss & landing_page.scss.

I am simply trying to style my landing page. However, I am unable to get any of the styles from my landing_page.scss to load. I can only get these styles to load if placed in application.scss.

Here is 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;
}

Anyone know what I am doing wrong? Why is it that sass or just plain css is not being applied when being placed in landing_page.scss?

Upvotes: 1

Views: 708

Answers (1)

kasperite
kasperite

Reputation: 2478

You want to @import partial to sass file. See http://sass-lang.com/guide to know how partials work.

In your case, you should rename landing_page.scss to _landing_page.scss and do @import landing_page in the application.scss file.

Upvotes: 2

Related Questions