Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails not compiling stylesheets in development after assets were precompiled

I ran the command rake assets:precompile in my console, then my stylesheets stopped being compiled in my application.css file when I go to localhost:3000...

Before, everything was perfect on development mode : write a stylesheet, require it in the application.css file, then see the styles being displayed in my view. So the asset pipeline "used to" work.

What I did to try to make it work (and failed) using other answers on SOF:

  1. In config/application.rb I added config.assets.enabled = true
  2. in config/development.rb I added the following :

    • config.serve_static_assets = false so that Rails doesnt look for my stylesheet in the public/assets folder
    • config.assets.compress = false
    • config.assets.debug = true to see the traces of the css being loaded
    • config.assets.compile = true
  3. I deleted the public/assets folder which got created after I ran rake assets:precompile - another way of deleting the folders is to run the command bundle exec rake assets:clobber but this didn't solve the problem

  4. I delete the tmp/cache folder
  5. restarted my server and cleared the browser cache everytime I was trying the sequence 1 thru 4
  6. tried changing the order in which I require my stylesheets in application.css

To no avail...

I also have the following setup

  1. application.html.erb

    <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>

  2. application.css

    *= require self

    *= require_tree .

    *= require custom

    *= require sidebar

    *= require flags/basic

    *= require flags/flags16

    *= require flags/flags32

    *= require font-awesome.min

In application.css in the browser I see this :

enter image description here

How come my rake assets:precompile could break my asset pipeline in development mode ? Thanks in advance for your help, I have spent at least 5 hours trying to figure this out and believed I have done everything I could to figure out a solution...

like image 746
Myna Avatar asked Jul 03 '14 22:07

Myna


2 Answers

Precompiled assets will supersede the uncompiled ones. The documented way to clear them is bundle exec rake assets:clobber. In Rails 3, all this does is delete the assets folder. Perhaps in Rails 4 it's more extensive (I don't have an installation here to test). Give it a try.

Note if you used an environment qualifier like:

RAILS_ENV=production bundle exec rake assets:precompile

to precompile, use the same qualifier to clobber.

However, the other thing that can defeat you is browser caching. Clear everything from the browser cache. Ideally try a completely different browser. I wasted a day figuring out that Safari requires selection of Safari | Reset... to purge everything.

like image 91
Gene Avatar answered Nov 13 '22 01:11

Gene


Delete your public/assets file and restart server and you will be up and running again and dont run assets:precompile again after

like image 35
Prince Abalogu Avatar answered Nov 13 '22 02:11

Prince Abalogu