图像和资产在rails 3.1.0上的生产服务器中不起作用

Uch*_*nna 11 ruby-on-rails ruby-on-rails-3 asset-pipeline

我将服务器切换到生产状态,我无法加载任何图像.这一切都在开发模式下工作正常但是当我切换到生产时它都停止工作我启用了server_static_assets但仍然无效.这样做的任何帮助

cai*_*nne 25

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

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

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

# 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
Run Code Online (Sandbox Code Playgroud)

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

RAILS_ENV=production rake assets:precompile
Run Code Online (Sandbox Code Playgroud)

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