How to exclude path from application.css Rails - ruby-on-rails

Here is my tree
stylesheets/
admin/
admin.scss
bootstrap_and_overrides.css.less
application.css.scss
categoria.css.scss
categories.css.scss
comments.css.scss
groups.css.scss
home.css.scss
ie.css.scss
images.css.scss
images.js.coffee
specs.css.scss
1 -> Is it possible (in application.css) to don`t load bootstrap_and_overrides.css.less?
My problem is..
my app have two layouts, one of then called admin, i would like to load bootstrap only in this layout, not for all application..
everyone?

You could add all your file separately in your application.css.scss, without bootstrap_and_overrides, like this :
/**
* application-print.css
*
*= require categoria
*= require categories
...
*/
and include bootstrap_and_overrides separtely
you could place your files in a directory and use require_tree ./normal/

Related

how to call css asset pipeline in grails

i already install asset-pipeline:1.8.10.
i'm confusing how to call css and javascript. i already googling. i found this video
but i havenot understood.
at folder grails-app/asset/stylesheets have based.css,bootstrap.css, main.css. last i create new file with application.css
but i only add this code to application.css
/*
*require bootstrap
*require based
*main.css
*require jquery-ui.custom
*require bootstrap
*require_self
*require_tree
*/
in gsp i use <asset:stylesheet src="application.css" />
but it likes not work. because the page is blank.
example :
grails-app/asset/stylesheets have based.css
based.css coding is
body
{
#FF0000;
}
at index.gsp
i call <asset:stylesheet src="application.css" />
then how about application's content?
there are a couple of things wrong in your application.css, first why do you import bootstrap twice? the second thing is, that you use require_tree with no folder given like: "require_tree . " or "require_tree subfolder"
here should be a working example:
/*
*require bootstrap
*require_tree .
*/
with a given folder structure like:
/grails-app/assets/stylesheets/
/application.css
/based.css
/main.css
and the bootstrap plugin required via BuildConfig.groovy.
The other aproach is to require different stuff directly instead of using the require_tree directive:
/*
*require bootstrap
*require based
*require main
*/

Custom folder under vendor not loaded on Rails 4

I bought a theme and want to apply the whole theme into my site.
I put the line in the scss file
*= require_tree ../../../vendor/assets/lenord-single-page-theme/css
but it didn't include the folder I want
Rails.application.config.assets.paths
=> ["pixnet_hackathon/website/dqa_streesful_server/app/assets/ace-admin-theme",
"pixnet_hackathon/website/dqa_streesful_server/app/assets/images",
"pixnet_hackathon/website/dqa_streesful_server/app/assets/javascripts",
"pixnet_hackathon/website/dqa_streesful_server/app/assets/lenord-single-page-theme",
"pixnet_hackathon/website/dqa_streesful_server/app/assets/stylesheets",
"pixnet_hackathon/website/dqa_streesful_server/vendor/assets/javascripts",
"pixnet_hackathon/website/dqa_streesful_server/vendor/assets/stylesheets",
".rvm/gems/ruby-2.1.0/gems/simple-navigation-bootstrap-1.0.0/vendor/assets/stylesheets",
".rvm/gems/ruby-2.1.0/gems/bourbon-3.1.8/app/assets/stylesheets",
".rvm/gems/ruby-2.1.0/gems/tinymce-rails-4.0.19/app/assets/javascripts",
".rvm/gems/ruby-2.1.0/gems/tinymce-rails-4.0.19/app/assets/source",
".rvm/gems/ruby-2.1.0/gems/tinymce-rails-4.0.19/vendor/assets/javascripts",
".rvm/gems/ruby-2.1.0/gems/bootstrap-sass-3.1.1.0/vendor/assets/fonts",
".rvm/gems/ruby-2.1.0/gems/bootstrap-sass-3.1.1.0/vendor/assets/javascripts",
".rvm/gems/ruby-2.1.0/gems/bootstrap-sass-3.1.1.0/vendor/assets/stylesheets",
".rvm/gems/ruby-2.1.0/gems/turbolinks-2.2.2/lib/assets/javascripts",
".rvm/gems/ruby-2.1.0/gems/jquery-rails-3.1.0/vendor/assets/javascripts",
".rvm/gems/ruby-2.1.0/gems/coffee-rails-4.0.1/lib/assets/javascripts"]
Just refer it using:
//= require_tree ../../../vendor/assets/lenord-single-page-theme/css/.
Hope it helps :)

Why do I get an undefined Foundation variable error in this SASS file?

I have a Rails 4 app, using the foundation-rails v5.2.1.0 gem, and one custom SCSS file for my application layout. When I use a variable from the foundation_and_overrides.scss file, I get the following error:
Undefined variable: "$header-font-family"
I've included relevant code below. I can post more if needed. Anyone know what's going on here?
From application.css:
*
*= require foundation_and_overrides
*= require_self
*= require_tree .
*/
From foundation_and_overrides.scss:
// We use these to control header font styles
$header-font-family: "futura-pt", sans-serif;
$header-font-weight: 400;
// $header-font-style: normal;
From custom.css.scss:
$include-html-global-classes: false;
#import "foundation/components/global";
.
.
.
.footer {
background-color: black;
color: white;
height: 100px;
font-family: $header-font-family;
}
You are getting the error because foundation_and_overrides.scss is executing after custom.css.scss. Best way to do this is to define your variables in a partial and import it in your main stylesheet after foundation.
First change the file name from
foundation_and_overrides.scss to _foundation_and_overrides.scss
and then import it in custom.css.scss file after foundation with
#import 'foundation_and_overrides';
Update
Rename your application.css to application.css.scss and custom.css.scss to custom.scss
In your application.css.scss remove *= require_tree .
And then import your main stylesheet with
#import 'custom'
I hope this helps
The cleanest way is to add the line
#import "custom";
to your file foundation_and_overrides.scss before the line
#import "foundation";
There's no need to remove *= require_tree . from application.css.scss as stated in the accepted answer. There's also no need to add require foundation_and_overrides to application.css if you leave require_tree . in there.
According to the Rails Docs:
If you want to use multiple Sass files, you should generally use the Sass >#import rule instead of these Sprockets directives. When using Sprockets >directives, Sass files exist within their own scope, making variables or >mixins only available within the document they were defined in.
So in this case the order of the directives (the lines in application.css that start with *=) doesn't matter because each of those files lives in its own scope and you can't access their variables from another scss file. That's why you want to either #import foundation_and_overrides and then custom, or #import your custom stylesheet into foundation_and_overrides.

Rails + Zurb - How to Priorize My Css

I want to override some properties from the css generated by Zurb Gem. The problem is that there is no link at the application to include these files. So if I put <%= stylesheet_link_tag "application" %> it will load before the hidden css files created by the gem. What can I do to solve that issue?
If you use the new asset pipeline system from Rails since 3.1 version. You can define the order of you loading in your application.css. The order define inside is maintain.
So by example you can do
/*
* = require 'foundation'
* = require 'my_css'
* = require 'my_hack_of_foundation
*/
Of if you use the css in application.css you can require in last of your file
/*
* = require 'foundation'
*/
body {
background: black;
}
/*
* = require 'my_hack_of_foundation
*/

Rails 3.1: howto include oocss CSS framework

I am trying to load the OOCSS framework into my new Rails 3.1 application. So far I have clone the project into /vendor/assists/stysheets/oocss, and tried to pull in the project from /app/assists/stylesheets/application.css
/*
* FIXME: Introduce SCSS & Sprockets
*= require ../../../vendor/assets/stylesheets/oocss/all
*= require_self
*= require_tree .
*/
However this does not work properbly, as the compiled css file just contains the two lines that should load the other files.
#import url("core/core.css");
#import url("plugins/plugins.css");
/*
* FIXME: Introduce SCSS & Sprockets
*/
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
You can use Sass (SCSS) here: http://sass-lang.com/
*/
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
You can use Sass (SCSS) here: http://sass-lang.com/
*/
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
You can use Sass (SCSS) here: http://sass-lang.com/
*/
Any ideas on how to pull this off?
UPDATE:
I did a dirty workaround by manually loading the CSS files in the correct order.
app/assets/stylesheets/application.css
/*
* FIXME: Introduce SCSS & Sprockets
*= require ../../../vendor/assets/stylesheets/oocss
*= require_self
*= require_tree .
*/
vendor/assets/stylesheets/oocss.css.scss
/*
* Core
*= require ../../../vendor/assets/stylesheets/oocss/core/libraries.css
*= require ../../../vendor/assets/stylesheets/oocss/core/template/template.css
* require ../../../vendor/assets/stylesheets/oocss/core/template/template_debug.css
*= require ../../../vendor/assets/stylesheets/oocss/core/grid/grids.css
* require ../../../vendor/assets/stylesheets/oocss/core/grid/grids_debug.css
*= require ../../../vendor/assets/stylesheets/oocss/core/module/mod.css
*= require ../../../vendor/assets/stylesheets/oocss/core/module/mod_skins.css
* require ../../../vendor/assets/stylesheets/oocss/core/module/mod_debug.css
*= require ../../../vendor/assets/stylesheets/oocss/core/media/media.css
* require ../../../vendor/assets/stylesheets/oocss/core/media/media_debug.css
*= require ../../../vendor/assets/stylesheets/oocss/core/content.css
*= require ../../../vendor/assets/stylesheets/oocss/core/heading/heading.css
*= require ../../../vendor/assets/stylesheets/oocss/core/spacing/space.css
*= require ../../../vendor/assets/stylesheets/oocss/core/table/table.css
*= require ../../../vendor/assets/stylesheets/oocss/core/table/table_skins.css
* require ../../../vendor/assets/stylesheets/oocss/core/table/table_debug.css
* Plugins
*= require ../../../vendor/assets/stylesheets/oocss/plugins/breadcrumb/breadcrumb.css
*= require ../../../vendor/assets/stylesheets/oocss/plugins/tabs/tabs.css
*= require ../../../vendor/assets/stylesheets/oocss/plugins/talk/talk.css
*= require ../../../vendor/assets/stylesheets/oocss/plugins/talk/talk_skins.css
*/
Best regards.
Asbjørn Morell

Resources