I'm upgrading a Rails 3 application to Rails 4. We have several servers and a large codebase, so I'm sending a small portion of traffic to the Rails 4 server to test that it works correctly.
An issue I'm having is that when compiling assets, the Rails 4 version is generating different asset hashes than the Rails 3 app. The new hashes are twitter-df693e1c56dc88f61e60a2ad023eb024.js
, versus twitter-7899bccf144efec6f5064e6b54b42be9.js
on the old app.
When this occurs, asset links from the Rails 4 server references files that don't exist on the Rails 3 servers, and vice-versa (This issue is exacerbated by CDN caching).
Is it possible to get the hashes to be consistent? As far as I can tell, both apps should be using MD5 for their digest:
Rails 4 app:
config.assets.configure do |env|
puts "Digest class = #{env.digest_class}" # Digest class = Digest::MD5
end
Not sure how to check the digest class on the Rails 3 app, but I believe it defaults to MD5 for that version of Sprockets.
Relevant version info:
Rails 4 app:
sprockets (2.11.3)
sprockets-rails (2.0.1)
rails (4.0.5)
Rails 3 app:
sprockets (2.2.3)
turbo-sprockets-rails3 (0.3.14)
rails (3.2.19)
Ruby: 2.1.2
The hash Sprockets generates is based in-part off of its own version:
So I don't think its possible to get a consistent hash between versions of it.
I did try overriding the Sprockets version constant (
Sprockets::VERSION = '2.2.3'
) out of curiosity, but didn't get the same hash as my current application with the old version, so I think something else must also be going into generating the hash.My current plan is to turn off our CDN and asset digests while I have 2 versions of Sprockets running in production.