04 Sep 2011, 12:38
Generic-user-small

Steve Chen (2 posts)

going through p2_0 and found that the rails31/depot_b/app/assets/stylesheets/products.css.scss would refuse to load. Need to remove the top 3 comment lines or use /* */ instead of // for it to work.

04 Sep 2011, 14:17
Samr_small_pragsmall

Sam Ruby (584 posts)

I don’t see that problem here. I will also note that those three lines are generated by Rails.

09 Sep 2011, 04:20
Cowboy_pragsmall

Scott Golaszewski (2 posts)

I’ve followed this part of the book through 3 times now, and the product styles aren’t working for me either. Since Steve suggested it worked after changing the comment lines, I tried that assuming maybe the file just needed to be touched or something. I’m still not seeing styles on the product index, but the source shows the generated stylesheet being loaded,

<link href="/assets/application.css?body=1" media="screen" rel="stylesheet" type="text/css" /> 
<link href="/assets/products.css?body=1" media="screen" rel="stylesheet" type="text/css" /> 
<link href="/assets/scaffolds.css?body=1" media="screen" rel="stylesheet" type="text/css" /> 

The only thing that seems weird is that there’s no reference to a .products class anywhere in the products/index.html.erb, but the class definitions are nested under a .products class. If I add the products class to the line_item_even and line_item_odd in the cycle, those dt’s get the styling. Adding the products class to other elements in that file don’t do anything.

The versions of sass installed with rails 3.1.0 are:

sass (3.1.7) sass-rails (3.1.0)

10 Sep 2011, 15:58
Generic-user-small

Ramon Maria Gallart (1 post)

Hi Scott,

I think that as it happened to me you have missed the line <body class='<%= controller.controller_name %>'> present on page 74 (PDF version) where application.html.erb is presented.

Greetings,

Ramon Maria Gallart

12 Sep 2011, 17:29
Generic-user-small

Ken Burgett (20 posts)

I downloaded the code from the link under the book image above yesterday, and I don’t have an ‘assets’ folder under ‘app’ in the depot_b folder, as shown on page 72. I think the new asset code examples are not fully baked yet. Also, Ramon found the referenced <%=controller.controller_name %> line in the pdf, but not in the depot_b/app/assets folder, since I don’t have the folder at all.

13 Sep 2011, 17:39
Cowboy_pragsmall

Scott Golaszewski (2 posts)

Thanks, Ramon. I kept skimming over that part since there wasn’t one of those indicator arrows in the sidebar. I guess I need to pay more attention. :D

28 Jan 2012, 16:00
Generic-user-small

Svetoslav Dankov (3 posts)

I followed the book every step of the way and the modified products.css.scss (downloaded from the link in the ebook) loads (I guess it loads because rails server does not throw any error) but it fails to render (the style is not applied to the products page).

As the OP suggested, deleting the three comment lines starting with “//” fixed this. You might want to modify the downloadable products.css.scss file to reflect that (or investigate further - I am on Win 7 x64, Ruby 1.9.3p0, rails 3.2.0, sass 3.1.12).

Thanks

21 Aug 2012, 03:58
Generic-user-small

Kees Briggs (1 post)

CSS, SCSS, SASS, … the double-slash comments that appear in products.css.scss are syntactically incorrect and should be removed, for sure.

21 Aug 2012, 12:38
Samr_small_pragsmall

Sam Ruby (584 posts)

The double slash comments are generated by Rails, and are valid SCSS:

http://sass-lang.com/docs/yardoc/file.SCSS_FOR_SASS_USERS.html#comments

03 Dec 2012, 03:38
Generic-user-small

Roberto Fernandez (1 post)

For some reason removing the double slash comments worked for me as well. Maybe some other hidden character in this file?

UPDATE: I indeed opened the file in VIM, removed the double slashes, typed them in again and saved the file and it works.

20 Jan 2013, 15:14
Generic-user-small

wolverine of kansas (1 post)

I cant even find the “assets” folder inside app folder. It is NOT there . I downloaded the source code that was in .tar format.

04 Mar 2013, 11:13
Generic-user-small

Jinhui Dun (2 posts)

I encountered the same issue after downloaded the code from the website and replaced the products.css.scss with the one Rails Scaffold generated for me, and that css file simply does not load. Found here and tried every method including remove the first comments or replace // with /*, everything works. Then finally I believe that Scott is right, we just need to “touch” the file to make it recognized by Rails. The reason is straight forward, the file we downloaded from network, their last modified data will be definitely earlier than the one Rails generated for us, so Rails is simply not re-loading it even we restarted the Rails Server. Maybe the author can confirm this and make necessary comment in the book, cause I think most readers will follow the same step (copy the long css code from network to replace the local one), and encounter the same issue.

04 Mar 2013, 13:24
Samr_small_pragsmall

Sam Ruby (584 posts)

Jinhui: that makes a lot of sense. Can I ask how you copied the file, and what operating system you use? I ask because I see Roberto mentioning vim which is uncommon on Windows, and I know that the cp command (by default) will give you a fresh time stamp. I’d need to investigate further to see what happens on Windows.

But in any case, you are right: Rails indeed won’t reload if the mtime is either unchanged or at an earlier point in time:

https://github.com/rails/rails/blob/master/activesupport/lib/active_support/file_update_checker.rb#L101

04 Mar 2013, 14:02
Generic-user-small

Jinhui Dun (2 posts)

Thanks Sam. I’m using Windows 7 Home version (32bit), and copied the file by just dragging it from WinRAR (with the zip file opened) to the target folder. And thanks to those advocators I’m also using gvim in Win, although still not quite familiar with it.

04 Mar 2013, 15:43
Samr_small_pragsmall

Sam Ruby (584 posts)

OK, I’m adding a paragraph to the “How to Read this Book” section in the Introduction (as this is where the download link is present), and I’m adding a paragraph to this point in section 6.2 as it is the point at which most people will discover this.

  You must be logged in to comment