简体   繁体   中英

Wrong fingerprint in Rails 3.1 asset pipeline for JS files in production

I'm deploying the project to the server after deploying CSS and images - it's working, but the JS doesn't work - 404. JavaScript hash in HTML and public/assets - mismatch.

In HTML: application-6851a5d9167871936c32da723dca0f23.js
In public/assets: application-95ecf5bab4b7984abe8c1c23b72a7679.js

Did you run 'rake assets:clean assets:precompile'?

Also, if you're using GIT, you'll need to 'git rm' the older versions of the assets too. You'll need to do something similar for other version control systems if you Production environment is updated by pushing a workspace (eg Heroku).

In your Development environment, Assets are fetched directly from your source base - so if you change them, you don't need to precompile again (saving you time during development). But, you can stumble on the assets fairly easily because of that.

Restarting the app fixed it for me.

Eg in the app's root directory:

touch tmp/restart.txt

or in Capistrano 3's deploy.rb :

namespace :deploy do
  desc 'Restart application'
  task :restart do
    on roles(:app) do
      within release_path do
        execute :touch, 'tmp/restart.txt'
      end
    end
  end

  after 'deploy:publishing', 'deploy:restart'
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM