I have a problem with Ruby on Rails rquire statements.
I want to add a reset.css file before the require_tree.
I have a application.css:
/*
*= require reset
*= require_tree
*= require_self .
*/
By doing this I am always gearing an error: wrong number of arguments (1 for 0). Where is the problem?
require_self should be without . argument. Here is specification of this directive. As you can see it doesn't have parameters.
Related
I am trying to incorporate bootstrap 4 into my Rails 5.2 project. Currently, my app/stylesheets/application.css, has the following in it:
/*
*= require_tree .
*= require_self
*/
The instructions, in addition to renaming it application.scss, call for deleting:
*= require_tree .
*= require_self
And adding:
#import 'bootstrap'
Isn't "require_tree ." needed to include all the stylesheets in the stylesheets folder? and the "require_self", to include any styles I may decide to add in the application.scss file?
So if I remove these two statements, would I need to include every single stylesheet individually, using an #import statement. For instance, if I have: user.scss, I would add:
#import 'user'
I've seen some examples where the require_tree and require_self are kept. Your advice is appreciated.
use asterisk to path like
#import "path/to/*"
if you add all sxss in 'stylesheet' path (ex: stylesheet/a.sxss, b.sxss)
#import "*"
else you add all sxss in 'stylesheet/page' path (ex: stylesheet/page/a.sxss, b.sxss)
#import "page/*"
In my rails5 application, I have application.css.scss and controller specific stylesheets such as home.scss, about.scss etc.
When I check the inspect in my browser, it seems application.css is loaded before home.css and about.css. Because of this, most of the overrides used in applications.css were simply ignored.
application.css.scss
/*
*= require_self
*= require material-design-iconic-font/css/material-design-iconic-font.min
*= require nprogress-turbolinks5
*= require app
*/
How can I load applications.css.scss as the last one in head section?
There is the following code application.css.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 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
*/
.table tbody > tr > td.vertical-align {
vertical-align: middle;
}
This file is in 'stylesheets' directory. There is also 'home.css.scss' file in the same dir. But if I move this style from 'application' file to 'home' file browser doesn't see this style. What's the trouble? How can I fix it? Thanks!
in my case I have imported bootstrap at the end of the file followed by styles, this must be the problem
*= require_tree .
*= require_self
*/
#import "bootstrap-sass-official/assets/stylesheets/bootstrap-sprockets";
#import "bootstrap-sass-official/assets/stylesheets/bootstrap";
.table tbody > tr > td.vertical-align {
vertical-align: middle;
}
also I'd say you should try to put require tree after require self:
*= require_self
*= require_tree .
this makes more sense.
From the Rails Asset Pipeline 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.
http://guides.rubyonrails.org/asset_pipeline.html
So in your case you can move the styles you declared in application.css.scss into a separate file (say: table_styles.css.scss) and then rewrite your manifest file as:
#import "bootstrap-sass-official/assets/stylesheets/bootstrap-sprockets";
#import "bootstrap-sass-official/assets/stylesheets/bootstrap";
#import "table_styles";
// Import any other files that would have been imported by require_tree
The advantage of this approach is that you can use sass variables and mixins and you have better control over the load order of your stylesheets.
I have installed these gems : font-awesome-rails and bootstrap (gem 'anjlab-bootstrap-rails', :require => 'bootstrap-rails',
:github => 'anjlab/bootstrap-rails')
In my application.css.scss, I have
*= require twitter/bootstrap
*= require_self
*= require_tree .
*/
#import "font-awesome";
#import "font.css.scss";
where the last file contains #import url("//fonts.googleapis.com/css?family=Open+Sans:300,400,600,700"); The problem, is that no icon is loaded in my html because fontawesome seems not to be fetched. So I installed the font-awesome gem, but it didn't change anything. Could someone help ?
Can you try this one in your Gemfile (outside of the assets group)? gem 'font-awesome-rails', '4.0.1.0' After you bundle install, make any change (i.e. add an empty line) to your application.css.scss to get it to re-compile.
I have a Ruby application, and here is my setup:
I have this HAML code:
.alert.alert-info
%p="This is the correct style."
The sidebar.css has this:
/*
* THIS IS THE MANIFEST FILE FOR THE LAYOUT: SIDEBAR
*= require_self
*= require bootstrap
*= require bootstrap-responsive
*= require bootstrap_overrides
*= require layout/buttons
*= require sidebar/base
*/
The web page renders the text "This is the correct style" but not the styling for it.
Here is the page with the styling documentation:
http://twitter.github.com/bootstrap/components.html#alerts
Any idea what I might be missing or need to set up still? The css styles are just not rendering.
Thanks!
Not sure if you use LESS or not, by I import Bootstrap like this:
#import "twitter/bootstrap/bootstrap";