Reputation: 13581
I'm a bit confused as it seems like the application.css is including itself twice, once when it lists the resources from the manifest and then a cache of that. So when I delete an individual file it still seems to stay alive inside the application.css file.
/*
*= require twitter/bootstrap
*= require_self
*= require_tree ./common
*= require_tree ./helpers
*/
Which works as expected and outputs in dev mode all the relevant individual files
# Do not compress assets
config.assets.compress = false
# Expands the lines which load the assets
config.assets.debug = true
<link href="/assets/twitter/bootstrap.css?body=1" media="screen" rel="stylesheet" type="text/css" />
<link href="/assets/application.css?body=1" media="screen" rel="stylesheet" type="text/css" />
<link href="/assets/common/announcement.css?body=1" media="screen" rel="stylesheet" type="text/css" />
<link href="/assets/common/button.css?body=1" media="screen" rel="stylesheet" type="text/css" />
<Blah blah>
This should be blank? Since all I have in my application.css file is the manifest and no actual css but instead i get all my concatenated code 106kb long.
IE if I remove a file in the common directory, it doesn't go away. It is no longer listed in the output but the css still appears from the application.css
Upvotes: 36
Views: 20602
Reputation: 3911
I know this is an old question, but one fix that worked for me is that I had nginx proxying to my development environment and it had a location ~ ^/(assets)/
block in the configuration. Either comment it out, or try restarting nginx to invalidate the cache. If you're developing, you'll likely just want to comment it out entirely.
I lost way too much time troubleshooting this until I remembered that.
Upvotes: 0
Reputation: 14051
@Agustin's solution does it for me but here are a few things you need to do:
Delete everything in /tmp/cache/assets
Add config.serve_static_assets = false
to development.rb or test.rb (credits to @Agustin)
Restart your server.
Make sure your application.js / .css is not cached in your browser. Go to http://localhost:3000/assets/application.js?body=1
and hit ctrl+f5 to force refresh (you can also try appending appending a randomizer param at the end: http://localhost:3000/assets/application.js?body=1&rnd=12343
If you get something else and ctrl+f5 still hasn't helped, you need to clear your browser's cache.
Skipping either of these steps returned a cached application.js / .css conflicting with my updates in single files.
Upvotes: 7
Reputation: 2200
There was one last step required for me, but I got it fixed. Here's what I did:
Then, I refreshed my screen in Google Chrome, and IT STILL DID NOT WORK. So, I launched Firefox and voila, it was actually working. This means that Chrome was caching the old files within the browser. So, I then cleared out the browser cache in Chrome, and it worked!
Upvotes: 0
Reputation: 71
The thing that worked for us was setting 'config.assets.debug = false'
This no longer set the HTML included CSS as href="/assets/bootstrap-new.css?body=1", instead set it up as href="/assets/bootstrap-new.css", which I think was the issue.
Upvotes: 3
Reputation: 26718
I had the same problem. Despite clearing tmp/cache and public/assets the minified application.css was still cached and served up from somewhere and my changes to individual css files were not getting served.
This worked for me:
in application.css remove the line *= require_self
restart server
that seems to remove the cache and if you click on application.css in your browser source you will no longer see the minified version
replace the *= require_self
back into the file and continue developing.
Upvotes: 1
Reputation: 656
The best way, that worked for me is to delete content of tmp/cache/* directory...
Upvotes: 4
Reputation: 901
There is currently (2012-09-24) a bug in rails/sprockets causing it to not properly detect imported files.
This should be fixed in rails 3.2.9 and later but in the mean time, you can work around it as follows:
You should now be seeing the correct css.
Upvotes: 38
Reputation: 1254
You might want to look at
https://stackoverflow.com/a/7854902/686460
"Adding config.serve_static_assets = false to development.rb will prevent loading files from /public/assets"
That did it for me.
Upvotes: 10
Reputation: 1779
I had a problem like this before. It was caused after I had precompiled the assets it was going after the applcation.css inside the public folder as well as in the apps directory. I'm not sure how to fix it so that it doesn't keep happening while in dev mode but if you delete your /public/assets
directory it should fix it.
Check and see if you have a public/assets folder, if you do and it's full, it's probably why you're seeing double.
Upvotes: 41
Reputation: 6714
The assets do their job better when running the app in production environment then you'll have loading only the application.css with all the files included, and compressed, there to reduce the server request and this application.css with the compressed styles will be cached.
http://guides.rubyonrails.org/asset_pipeline.html
Upvotes: -5