The Rails application is not working in the production environment, so-called production environment.

Asked 2 years ago, Updated 2 years ago, 122 views

The Rails application is not working in the production environment, so-called production environment.
In the test environment, css, image, and javascript are successfully compiled and reflected each time, but in the production environment, only css is not reflected.
(assets:precompile is complete and loaded correctly, but it doesn't work at all.)

As a test,

  • assets:Verified successful file generation under app/public/assets after precompile execution
  • Cleaned under app/public/assets (for some reason, the command did not clean, so hand
    ) motion rm)
  • I deleted the cache and tried it from the secret window just in case
  • Restarted Unicorn, Nginx (no error log)
  • Verified if it will be reflected in the test environment (under app/assets will be compiled each time)
  • Doubt permission error under app/public
  • Verified correct view by specifying path directly from url
  • Read the generated source and check for interference with extra stylesheets.
  • Verified everything pointed out in http://qiita.com/metheglin/items/c5c756246b7afbd34ae2

The environment is as follows:I am troubled that only css is not loaded.
Thank you for your cooperation.

  • Rails 4.2.0
  • Ruby 2.2.0
  • rbenv0.4.0
  • Unicorn 4.8.3
  • Nginx 1.6.2
  • MySQL 5.5.40
  • EC2 Amazon Linux AMI 2014.09.1 (HVM) (Production Machine)
  • Git (Repository Machine)

ruby-on-rails ruby nginx aws unicorn

2022-09-30 20:50

3 Answers

Of course, I think I have already checked it, but

config.assets.css_compressor=:ass
config.assets.enabled = true
config.assets.compile=true

<Application Route Directory>/config/environments/production.rb
Configured in and

$touch<Application Route Directory >/tmp/restart.txt

Why don't you delete the contents of tmp/cache and restart the web server?When it still doesn't work

 rake assemblies:precompile

When I try things like that, I feel that they work well.
I think I've already done it, but I remember that the browser cache was erased so that it wouldn't be confusing, and the display would be updated if I accessed it several times until the update was reflected.
I'm sorry that I didn't know exactly how it works around here, so I only answered from experience, but I hope I can be of help.
Most browsers have the ability to read the source, so it would be easier to view the source and check the file contents of the CSS file in the head tag (link tag).


2022-09-30 20:50

How about taking resources to S3 using AssetSync?

Setting the bucket policy properly should help isolate the problem.


2022-09-30 20:50

I rm the public/assets once and precompile again and got css.
I have tried many things, but I think there is a json file called .sprockets-manifest under public/assets, and I am managing the version of the precompile file, but I think it was because it was old.
So I deleted everything and tried again.I would appreciate it if you could help me.


2022-09-30 20:50

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.