Joined March 2013
·

Andre Kramer

Wirelab
·
Hengelo, Netherlands
·
·
·

I good thing to remember is that you need the manifest.json stored in public/assets. So you can't just add a rake assets:clobber to the rake assets:clean hook or rm -rf public/assets Which I learned the hard way. Without the manifest, rails wont be able to find the assets. It tries to find the fingerprinted filepath stored in the manifest, and uses the asset_host to find the file on S3.

I say assets:clean because that is run just before the slug compress during the build heroku does. Normally assets:clean removes old versions of your assets. But since it's a fresh slug it doesnt delete anything (sorry if Im wrong).

You could refactor your script by

Rake::Task["assets:clean"].enhance do
#You probally don't need to loop the app/assets folder, just remove it. I need to test this
  ["#{Dir.pwd}/public/", "#{Dir.pwd}/app/assets/"].each do |dir_path|
    records = Dir.glob("#{dir_path}**/*")
    records.each do |f|
      if !(f =~ /manifest.*.json$/)
        File.delete(f) if File.file?(f)
        puts "removing #{f}"
      end
    end
    puts Dir.glob("#{dir_path}**/*")
  end
end
Achievements
29 Karma
0 Total ProTip Views