3

I operate Rails 3.2.13 and I ran a

rake assets:precompile

In order to activate some CoffeeScript that wouldn't fire otherwise, and it completely ruined my pages layout, which was fine until then. The menu of my application is now vertical instead of horizontal and the rest of the pages is subsequently invisible.

I use Bootstrap and I suspect this has been updated, for some reason, but it's too much work to change it, if I only knew why it has changed and what has changed anyway...

I would like to go back to the former state of my layout.

Is there any way to roll back ?

BENARD Patrick
  • 30,363
  • 16
  • 99
  • 105
cedric
  • 223
  • 5
  • 12
  • you should check your bootstrap version and set the proper one. do you know which version are you using? – sissy Mar 10 '14 at 15:22
  • In my gemfile, I have : gem 'bootstrap-sass', '~> 3.1.1' – cedric Mar 10 '14 at 15:43
  • this is the last bootstrap version, so it's not a question of bootstrap update that has messed up your layout (unless you changed your gemfile recently and added the bootstrap version...then if you were using 2.3 and updated, this could have messed up). Precompiling assest also could not affect your layout. Can you post your layout here? – sissy Mar 10 '14 at 15:51
  • That's some code. Here is the part that is now vertical instead of horizontal : – cedric Mar 10 '14 at 15:59
  • That's some code that won't fit here. Here is the part that is now vertical instead of horizontal : – cedric Mar 10 '14 at 16:05
  • I used 'bootstrap-sass', '2.1' before, and it is possible that I never recompiled assets since I changed that... – cedric Mar 10 '14 at 16:08

3 Answers3

4

remove public/assets

explanation: the precompile task compiles your assets, usually in app/assets, and places them in your public folder/assets folder.

If you want to go back to the state prior to the precompile, just remove public/assets

rm -fr public/assets.
lsaffie
  • 1,764
  • 1
  • 17
  • 22
  • 1
    I just did that, but my layout is still ruined...It doesn't seem to change anything. – cedric Mar 10 '14 at 15:42
  • is it deployed to a server or are you running this locally? What environment are you running it on? – lsaffie Mar 10 '14 at 15:49
  • This is my local dev environment. – cedric Mar 10 '14 at 15:56
  • 1
    Then the precompilation shouldn't make a difference. It's only for production environment unless you're explicitly telling it to use precompiled assets. If using git, look at the history and checkout previous version to find one where it was ok. – lsaffie Mar 10 '14 at 16:18
  • Also, try to open the page in incognito mode if using chrome and clear cookies, cache, etc in other browsers. It may have to do with caching – lsaffie Mar 10 '14 at 16:19
  • Obviously, precompiling assets does make a difference, because Coffeescripts that didn't fire before this precompilation now do fire. And that is precisely why I launched the precompilation.So what should I understand ? – cedric Mar 10 '14 at 17:06
  • And I cleared my browser's cache. But that doesn't make a difference. – cedric Mar 10 '14 at 17:07
  • 1
    your question was how to undo what assets:precompile does, by removing the assets folder in public, you'll accomplish that (as stated above.) I believe other folder is being read by your server. If you're running your server in development mode, it's probably reading them from app/assets (if it's a vanilla rails app) Not sure I could be of any help at this point.. Perhaps this link may help http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets – lsaffie Mar 10 '14 at 18:21
  • RVM wouldn't have an impact. I suggest debugging this by using the browser console. Look at the assets being served (CSS, js) make changes locally and make sure they are reflected on the page. If they aren't they're getting read from somewhere else. If running in dev mode, they should be read directly from the css in app/assets – lsaffie Mar 11 '14 at 13:20
1

I had this problem too. In addition to removing the precompiled assets under the public folder, I also had to clear the tmp/cache folder.

cash22
  • 430
  • 3
  • 20
0

ok, this should be the problem: you changed your bootstrap version from 2.1 to 3.1 and the syntax you're using is not suitable for 3.1. That's not a question of compiling assets, just that from version 2 to version 3, there's a totally new syntax.

Have a look here:

http://getbootstrap.com/migration/

Then set your bootstrap gem version to 2.1 in your gemfile and run bundle install. Everything should go back to the right place.

sissy
  • 2,908
  • 2
  • 28
  • 54
  • I think I can't go back to 2.1 because I use something that I remember required explicitly 3.1, and that is why I had to switch to that new version. But I don't understand why it is the precompilation that caused the problem. I had done bundle installs before with Bootstrap 3.1 and it didn't cause that problem. Only the rake assets:precompile did... – cedric Mar 10 '14 at 17:10
  • I had a look at your link for the bootstrap migration. I must say it's all Chinese to me. No tag that I use seems to be in these lists, as such, although I see the "Navbars" have somehow been updated, for some reason that is beyond me. I don't think I've got the skills required to analyse what's wrong with Bootstrap versioning. All I want is to go back to my former state of layout, just before I did :rake assets:precompile, because, again, I'm positive that it was what ruined everything. I did nothing else in between. – cedric Mar 10 '14 at 17:33
  • ok i'll try to be clearer: if you have a layout based on the old classes of bootstrap, these won't work anymore with the new version. That's why you are not seeing any of the classes you are using in the documentation. And also, running assets:precompile does not affect your layout: if you deleted the public/assets folder, the precompiled assets are totally gone. Also, to be surer the precompilation is not having effect, you can try to run your application with development environment where you will (generally) have specified `config.assets.compile = true`, saying not to use precompiled assets – sissy Mar 10 '14 at 18:48
  • > running assets:precompile does not affect your layout. Well, it does very much, and that is precisely my problem : my layout was ruined following my rake assets:precompile and nothing else. – cedric Mar 11 '14 at 09:43
  • > if you deleted the public/assets folder, the precompiled assets are totally gone. The layout is still ruined after deleting the public/assets entire content. What's wrong with my setup ??? – cedric Mar 11 '14 at 09:47
  • if you're sure the precompilation process ruined your layout then the only way to undo it, is the one we're suggesting you since yesterday. If you already did it and it had no effect, then it means the problem it's not that. If you keep thinking the problem is there, there's no other way to solve it. Have you tried running in development mode with config.assets.compile = true? this does not use precompiled assets version. The only solution to convince you the problem is not there is to create a totally new app and move your code there without public folder. You'll see it's ruined anyway. – sissy Mar 11 '14 at 09:53
  • In my application.rb, I have : config.assets.enabled = true config.assets.initialize_on_precompile = false config.assets.version = '5.0' In my environment.rb, I have : config.assets.compress = false config.assets.debug = true – cedric Mar 11 '14 at 14:11
  • don't you have different environments for development and production? if anything is specified then, rails should be compiling your assets. What i didn't think is you can check if you're using precompiled assets just opening your browser developer console and check if your stylesheets (or js also) have a fingerpring. If not you're not using precompiled version of your assets. – sissy Mar 11 '14 at 14:22
  • My production is on Heroku. Here, I'm talking only of development. My assets are not fingerprinted on my development console. Again, the situation is the following : I had a nice layout alright, that I had for months. Some time ago, I had to change the bootstrap version in my gemfile and I did a bundle install and I made a few adaptations and it was fine. Then, I developped new Coffescripts and they wouldn't fire. I thus did a rake assets:precompile, and the Coffescripts subsequently fired alright but my layout was then ruined. There was no other action from me than this rake command. – cedric Mar 11 '14 at 14:40
  • i see but this doesn't make any sense as we're trying to tell you. We have to look for a different solution. If your application is in dev env and not using precompiled assets (this we are sure by now) how can precompilation affect your coffeescripts? Maybe you moved them in the proper location that's why they're working. If you can post your complete layout in your question (properly formatted with code indentation) i could make a try, otherwise i have no other resources, sorry. – sissy Mar 11 '14 at 15:06
  • I found this http://stackoverflow.com/questions/19866318/run-rake-assetsprecompile-when-switching-back-and-forth-between-bootstrap-gem-v?rq=1 and this exactly my problem : I had both versions of bootstrap-sass loaded at the same time. I now removed the most recent version (3.1.1.0) and changed my gemfile accordingly and did a bundle. And my old fine layout is back, except I had to remove the requires for bootstrap/alert and bootstrap/dropdown in my application.js – cedric Mar 11 '14 at 15:12
  • finally that's what i was trying to say since yesterday: the problem was the bootstrap version not the precompilation...a thank you for the patience would be nice ;) – sissy Mar 11 '14 at 15:15
  • But questions remain : 1) why do I need to run a rake assets:precompile to activate my Coffescripts ? 2) Why did this mess up my layout, when I had bundled the new bootstrap version earlier without a problem ? This is beyond me... – cedric Mar 11 '14 at 15:16
  • the precompilation was the trigger. And the question is why ? – cedric Mar 11 '14 at 15:21
  • Yes, thank you for your patience anyway, but I still don't understand what went on... – cedric Mar 11 '14 at 16:26