How to clean assets in rails 4

Gentle reminder, do not forget, in rails 4

rake assets:clean

seems to work, but actually does nothing. That is not entirely true: it only cleans the old assets, leaving the three most recent versions of the assets intact. So it is a like a mild cleaning, a throw-away-the-garbage-clean, a bring-those-old-clothes-you-never-wear-to-the-thriftstore-clean.

But sometimes that does not cut it. Sometimes, don't ask me why, building my assets does not seem to work, my code is just not being picked up. And then you need to do use brute force cleaning (throw everything out). Run

rake assets:clobber

to actually clean the assets. The logic or meaning is lost on my me (clobber?), but this works.

Timo 2014-05-07 14:41:28 UTC

Presumably the logic with three recent assets version is that if your rails application has send emails which are referring to your assets then they can be still found even if the emails are read some days later. Btw. clobber removes the whole assets directory. For me too the meaning is lost...

nathanvda 2014-05-08 07:20:26 UTC

Yeah, I think they mainly wanted to introduce a clean that would just do clean up the old versions. Before we only had the "hard clean" and no inbetween version that would just remove the old versions. So I guess that is a good thing. The emails thing you mentioned is a good one: I did not think of that.

Jake Han 2015-02-08 11:22:45 UTC

Wow, solid information. Thanks for the email tip as well.

Ryan 2015-02-08 20:02:35 UTC

Great article, and to those non-native english speakers ;)

Add comment

Recent comments