← Back to Upcase

Rails doesn't pick up any new style changes


(Anthony) #1

Hi, I’m not sure what’s going on, but since recently my Rails 4.2 app isn’t picking up any changes to my stylesheets in development mode.

To run a stylesheet, only for the homepage, I added this line to my home view page:

  <%= stylesheet_link_tag "onepage-scroll" %>

and added this configuration to config/initializers/assets.rb

Rails.application.config.assets.precompile += %w( onepage-scroll.css )

Then I ran rake assets:precompile

I’m not sure if precompiling my assets in developments has caused this issues, I’m just guessing in the dark here.

I tried to solve this by running rake assets:clean and restarting the server, but that didn’t solved it.

my other stylesheets are just imported in the app/assets/stylesheets/application.scss file

/*
 *= require font-awesome
*/

@import "bourbon";
@import "base/base";
@import "neat";

@import "partials/nav";
@import "partials/footer";
@import "partials/layout";
@import "partials/flashes";
@import "partials/tables";
@import "partials/breadcrumb";

@import "partials/home";
@import "partials/news-grid";
@import "partials/team";
@import "partials/researcher-details";
@import "partials/output";

@import "partials/admin";
@import "partials/admin-add";
@import "partials/admin-show";

My project is at https://github.com/acandael/adlit-rails

Any help or suggestion are very appreciated,

Anthony


(Tom Ridge) #2

Hi Anthony,

I just ran your app locally and am having no issues with the css file loading, though I didn’t worry about precompiling the assets. Have you refreshed your browser to try reloading the changes?


(Anthony) #3

Hi Tom,

Thanks for looking into this. Refreshing my browser doesn’t help. I just changed some styles and it doesn’t have any effect whatsoever. This is very strange, also when I implement some Bourbon mixins like

@include outer-container;

or change the span-columns mixin like:

@include span-columns(8);

it doesn’t have any effect whatsoever.

greetings,

Anthony


(Tom Ridge) #4

Hi Anthony,

No problems, I believe because you have the assets precompiled, its not going through to sprockets as its already found some assets to utilise. Can you try deleting those compiled assets and letting me know how you get on?


(Anthony) #5

I removed the line

Rails.application.config.assets.precompile += %w( onepage-scroll.css )

from config/initializers/assets.rb

I removed the line:

  <%= stylesheet_link_tag "onepage-scroll" %>

from the homes index view page

then I ran

rake assets:clean

and restarted the server, but still changes to my stylesheets don’t have any effect.


(Tom Ridge) #6

Hi Anthony,

I’m assuming you’ve tried force-refreshing your browser too? cmd + F5 on a mac should do it. If not let me know and I’m happy to pair with you and take a quick look.


(Anthony) #7

Hi Tom,

When I pushed cmd + F5 on my Mac, voice over was started. I didn’t know I had this feature on my machine, so know I know : )

It would be great if you could pair with me, how does that work?

greetings,

Anthony


(Tom Ridge) #8

Sorry mate, my bad, try cmd + shift + r .

send me a private message with your email and ill send you a link to screenhero.


(Geoff Harcourt) #9

@acandael, did you restart your Rails server? Settings like what assets are supposed to be precompiled or included I think are set at startup. Editing an already included stylesheet shouldn’t require a restart, but a brand-new stylesheet might.


(Anthony) #10

@Tom, @Geoff, I think something seriously messed up my application, so I decided to rebuild the application from scratch. Now everything runs fine.

To implement the onepage-scroll.css stylesheet for the homepage, I use page styles with the style-tag in my homepage view template. I know, it isn’t pretty, but it works.

The only issue I had to fix was that the onepage-scroll css defines fixed positioning for the html-element. When clicking a link on the homepage, because of turbolinks, the html-element of the referenced page also had a fixed positioning.

So to fix that issue, I had to turn off turbolinks with:

data: { no_turbolink: true } 

in the link element.

That said, I think it’s the last time time I use the One Page Scroll plugin in a Rails project. It gave me a lot headaches : )

Also Turbolinks is giving me a lot of headaches, I really hope they dish this feature in Rails 5.

anyway,

thanks for your help,

Anthony