Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Mark Melin
Mark Melin
4,239 Points

Responsive bootstrap for rails

Hi everyone, Does anyone know how to appropriately use the responsive bootstrap.css within rails? It seems to me when I create an additional experiment project (with the same html and css index code) on the side with just linking only the 2 stylesheets works fine. Works: <link rel="stylesheet" href="css/bootstrap.css"> <link rel="stylesheet" href="css/bootstrap-responsive.css"> This is where I am confused. It seems my problem is using style link tag that loads all the css files from each page within the application.html.erb file: Does not work: <%= stylesheet_link_tag "application", :media => "all" %>

How would I make it so that it only loads 2 style sheets instead of all? I have tried installing the sass gem and has got me no where. Would like to know how to do this for efficiency reasons but I'm all ears if there's a better solution. Thanks in advance.

1 Answer

Ricardo De la Fuente
Ricardo De la Fuente
6,782 Points

You can use the stylesheet_link_tag to specify which files to include & their order like this:

<= stylesheet_link_tag "css1", "css2", "css3", etc %>

I don't know if you've generated a scaffold in your project or not but that will typically generate a matching scaffold CSS file which you may want to remove all styles from (if you delete it completely, it will be added to your project the next time you generate a scaffold). You can also add or remove CSS files using the application.css file in your assets directory. The following lines include the application.css & scss files for instances:

 *= require_self
 *= require_tree .

For more info, check out: http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/stylesheet_link_tag