【问题标题】:Precompile assets not load in production预编译资产未在生产中加载
【发布时间】:2016-10-26 08:21:55
【问题描述】:

即使在我运行 rake assets:precompile RAILS_ENV="staging" 之后,我的 Rails 应用程序也无法在 staging 环境中正确加载资产。

这是我的暂存配置:

  config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?

  config.assets.js_compressor = :uglifier

  config.assets.compile = false

  # Generate digests for assets URLs
  config.assets.digest = true

  # config.force_ssl = true

  # Expands the lines which load the assets
  # config.assets.debug = false

  config.log_level = :debug

Here's a screenshot of my browser's development console.

路径错了……有人知道为什么吗???

【问题讨论】:

  • 为什么设置config.assets.compile = false?
  • 您是否使用此主机 (192.168.0.71) 作为您的暂存 URL?如果没有,您是否可以从您的机器访问此主机?

标签: ruby-on-rails asset-pipeline


【解决方案1】:

您尝试将config.assets.compile 变量设置为false?在大多数情况下,这是主要问题!我期待帮助。

【讨论】:

    【解决方案2】:

    我发现了问题。将 Rails 3 迁移到 4 后,我忘记将此配置放入 initializers/assets.rb

    Rails.application.config.assets.precompile += %w( some.js some.css )
    

    谢谢你们!

    【讨论】:

      【解决方案3】:

      配置config.action_controller.asset_host

      【讨论】:

      • 主持人是对的....是192.168.0.71:3050。问题是文件夹样式表是资产。
      猜你喜欢
      • 1970-01-01
      • 2016-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-07
      • 2016-10-14
      相关资源
      最近更新 更多