0

I am having problem with referencing to the stylesheet contained in the assets/stylehsheets folder. Here is my layout implementation:

<!DOCTYPE html>
<html>
<head>
  <title>iOSScreencast</title>
  <%= stylesheet_link_tag "application", :media => "all" %>
    <%= stylesheet_link_tag "bootstrap.min", :media => "all" %>

  <%= javascript_include_tag "application" %>

  <%= csrf_meta_tags %>
</head>
<body>

<%= yield %>

</body>
</html>

When I run the page it shows that it is looking for the "bootstrap.min" in assets folder. The asset pipeline is enabled.

2
  • This is how the assets pipeline works. It will treat all the assets as they are kept directly under assets directory. Commented Feb 5, 2013 at 5:11
  • guides.rubyonrails.org/asset_pipeline.html - good information here as well Commented Feb 5, 2013 at 5:19

2 Answers 2

1

A better solution would be to load in bootstrap through the asset pipeline.

To do this go to your app/assets/application.css file and add: require 'bootstrap.min' above the other requires in the file.

The advantage of doing it this way is that Bootstrap is compiled in with the rest of your application CSS, which makes the loading of your page generally faster.

Sign up to request clarification or add additional context in comments.

1 Comment

I placed the bootstrap.min in assets/stylesheets and then in application.css I added *= require 'bootstrap.min'. When I run it get an error saying could not find bootstrap.min.css.
0

Your best bet is going to be to use the bootstrap-sass gem, which you can include by using gem 'bootstrap-sass', '~> 2.0.4.0' in your gemfile. Then you don't need to explicitly state it in your stylesheets. Instead, use a file for your custom styles:

<%= stylesheet_link_tag "application", :media => "all" %>
<%= stylesheet_link_tag "custom", :media => "all" %>

And then in custom.css.sass, use the @import directive to include bootstrap:

@import "bootstrap"

That'll be the easiest way to include Bootstrap in your app.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.