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

Help installing Bootstrap theme into Rails project

I downloaded a theme made with Twitter Bootstrap, but I am having trouble on how to install it into my Rails application so that it will appear on my web app. I have tried installing the CSS files for the theme into the Stylesheets folder of my app, then changing the require_tree command in the application.css file to match but it didn't work. What am I doing wrong? Thanks for your time!

9 Answers

Well how are you editing your application.css file? Some code here will help us diagnose your issues.

Also remember that bootstrap is not just css, but there is also a js file too which is needed for some of the elements you may want to use.

Well for people to better help you, posting the code you are trying helps us troubleshoot for you.

The issue is in the way you post css files into application.css

*= require reset
*= require normalize
*= require typography
*= require_self
*= require grid
*= require flatui_elements
*= require navigation
*= require font-awesome
*= require_tree .

Notice that they don't have .css after them, there are no quotes, etc. These are my css files that I have to have lined up in a certain order. Notice I have reset first, then normalize, then add my typography, then require_self is the application.css file.

Then the very last one is the require_tree. That means it will then insert all other css files from your css folder (in alphabetical order). If you don't need a css file to happen before another, then it can just sit in the css folder and will get added with require_tree.

Do you have

*= require_tree .

Notice there is a space and period after tree. That should be the last line. Without that, any css files in the sylesheets folder will not be included.

How do you know it's not working? What are you expecting to see that you aren't seeing?

You also many want to restart your rails server to make sure that older files weren't cached. You can see on your rails server log in the terminal which files are being loaded and make sure that the proper css files appear there.

I'm pretty sure I know what's wrong. To use a bootstrap theme, you still need to have bootstrap installed. The theme just overrides properties form bootstrap, but still needs the original bootstrap.

So, your application.css file should look like this:

*= require_self
*= require boostrap
*= require boostrap_theme
*= require_tree .

You will need to change to match the specific file names.

Hi Brandon! Thanks for the very quick response. I'm not sure what you mean by your first question (forgive me, I'm very new at this). The only code I have in the application.css file is

require "flattythemecode.css"
require_self

I edited my code and stripped the unnessecary elements as you suggested to no avail. Could the problem lie in the way I added the CSS file into the application? Here is the updated code:

*= require flattythemecode
*= require_self 

When I made the suggested changes, my app seemed to have lost its Bootstrap styling...even when I require Bootstrap.

I added that and it still isn't working. Do I need to delete all other stylesheets except for the them?

I'm expecting to see the theme on this site appear. I made the changes but the theme doesn't seem to have taken effect. I also restarted the server.