0
votes

I try to deploy my app in production, when using assets pipeline with command "RAILS_ENV=production rake assets:precompile", I find the hash value not the same as the one in my local precompile(but the same machine compile result is the same), eg:

production: login-23ec3a8268b84dd41a8247f0152e9263.png

local: login-1fdc804afc03e64346d254c5fbd1045c.png

but the code base are all the same. Then I try to precompile it in different machine, the result is all different.

So could someone help me or point out what mistake I have. Thanks very much.

Update:

After debug, I find if the absolute path is the same, different machine can compile out the same hash value: eg:

local /Users/user/MyApp: login-1fdc804afc03e64346d254c5fbd1045c.png

remote /Users/user/MyApp: login-1fdc804afc03e64346d254c5fbd1045c.png

but what I want is the compiled assets hash value doesn't related with absolute path

Finally I figure it out:

I'm using angular-rails-templates-0.2.0, it has a default config: https://github.com/pitr/angular-rails-templates#advanced-configuration

And I haven't modify this config. This lib register modify Rails.application.assets.version(this is the key to calculate all the assets' hash), while it calculate this version with rails absolute path in MD5, this is the reason why the same path machine will got the same compiled assets.

Solution: add default config in application.rb: config.angular_templates.inside_paths = ['app/assets']

1
I also got stuck with this with codedeploy. We deployed on two servers but when I compile the assets. I cheched hash value in the file name. My file name is applicaton-hast_value.ccs. It is not the same between each servers. I don't know what is going on. Any body can resolve that problem?. Please help me and Thank in advance.Sơn Lâm

1 Answers

0
votes

What is your precompile command? You should append your target environment explicitly like below.

rake assets:precompile RAILS_ENV=production