本文介绍了图像和资产在 Rails 3.1.0 上的生产服务器中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将服务器切换到生产环境,但无法加载任何图像.在开发模式下一切正常,但是当我切换到生产模式时,一切都停止了,我启用了 server_static_assets ,但仍然没有任何效果.对此有任何帮助

I switched my server to production and i cannot get any of my images to load. It all works fine on development mode but when i switched to production it all stopped working i have enabled server_static_assets and still yet nothing works. Any help towards doing this

推荐答案

以下是您可能遇到的一些问题:

Here are a few problems that you might be having:

1 - 您的生产配置可能不正确.如果您从早期的 3.1 候选版本开始,并且在此过程中一直在更新,则这种情况尤其可能发生.在 rc4 和 3.1.0 版本之间,production.rb 的建议选项发生了很大变化.

1 - Your production configuration may not be correct. This is particularly likely if you started out with an early 3.1 release candidate, and have been updating along the way. The suggested options for production.rb changed quite a bit between rc4 and the 3.1.0 release.

确保您的 production.rb 设置包括:

Make sure that your production.rb settings include:

# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false
# Generate digests for assets URLs
config.assets.digest = true

2 - 您可能忘记预编译您的资产

2 - You may have forgotten to precompile your assets

RAILS_ENV=production rake assets:precompile

3 - 您可能忘记重新启动 Web 服务器以获取 production.rb 中的更改.

3 - You may have forgotten to restart your web server to pick up the changes in production.rb.

这篇关于图像和资产在 Rails 3.1.0 上的生产服务器中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 12:17