0

I'm following Michael Hartl's rails tutorial (Chapter 5, section 5.1.2). The app was working fine until I followed this step, which was to create a new file:

app/assets/stylesheets/custom.css.scss

then add in:

@import "bootstrap";

I then restarted my rails server (hosted locally) and received this error message when navigating to the previously working:

http://localhost:3000/static_pages/home

Here is the error message that was returned:

Errno::ENOENT in StaticPages#home 

Showing /Users/chows/rails_projects/sample_app/app/views/layouts/application.html.erb where line #5 raised:

No such file or directory - /Users/chows/rails_projects/vendor
(in /Users/chows/rails_projects/sample_app/app/assets/stylesheets/static_pages.css.scss)

2: <html>
3: <head>
4:   <title><%= full_title(yield(:title)) %></title>
5:   <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
6:   <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
7:   <%= csrf_meta_tags %>

app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb__2762850417459261999_70126593557460'

I'm very new to this and I'm not sure what went wrong. Would appreciate any help. Thanks!

chows
  • 1
  • 2
  • Same problem in chapter 3. Try this, it really helped: http://stackoverflow.com/a/7629434 – Dmitriy Aug 31 '14 at 18:51
  • @DmitriyLuganskiy Thanks! this solution helped me. To anyone else reading, I removed app/assets/stylesheets/application.css and the app is back up and running. I'm not sure if this file is required later in the tutorial though. – chows Sep 02 '14 at 03:26

4 Answers4

0

Hey chows I ran into exact same problem, this is how I managed to fix it.

On the book Michael asked to use gem 'bootstrap-sass', '2.3.2.0', I tired everything to work with this version of gem, the only solution I found that worked is to use latest version of gem 'bootstrap-sass', '3.2.0.1'.

replace 'bootstrap-sass', '2.3.2.0' with gem 'bootstrap-sass', '3.2.0.1' run bundle update follow by bundle install.You'll notice that some css content will be off, try to fix it by visiting latest official bootstrap documentation.

cheers

Ray.Rai
  • 43
  • 6
0

I tried both of those solutions and they both run into different problems. The 3.2.0.1 makes it so that it now complains about some images asset not being there, and removing the application.css makes it so that it doesn't actually apply the bootstrap. What I did to fix your problem was just mv vendor to one directory higher e.g.

mv vendor ../

in your sample_app (or whatever you named your current repo) and that worked. Not sure why this is needed though.

Though I think my solution is just a workaround and not correct because according to the book, "vendor/assets: assets from third-party vendors" would imply each app would have a different set of third-party vendors (or at least I'd imagine there would be)?

Either that or bootstrap needs to be configured to read the app's vendor and not directly off of the work directory (not sure how this is done though).

0
mv vendor ../

(thank you Wong)

make sure you bootstrap-sass back to the one set in the book, 2.3.2.0.

Will Taylor
  • 1,994
  • 2
  • 23
  • 36
0

Just an update to my own question in case anyone faced the same issue as I did.

I tried removing:

app/assets/stylesheets/application.css

and the application loaded fine. However, the app still did not load the bootstrap, and it looked nothing like Hartl's. I also felt like this did not properly resolve the issue.

I then found this solution which worked for me: Bootstrap is not working with Rails 4

To quote:

There is a known issue in sass-rails that is causing this. https://github.com/rails/sass-rails/issues/191

Try locking sass-rails to version 4.0.3, delete Gemfile.lock and run bundle install again.

  • Answer provided by user yetti

This worked for me, and I'm back on track. Thanks for all the solutions posted!

Community
  • 1
  • 1
chows
  • 1
  • 2