【问题标题】:Running rails in production mode locally在本地以生产模式运行 rails
【发布时间】:2016-02-23 12:16:47
【问题描述】:

我正在尝试使用以下命令在生产模式下运行 rails(对此不太了解):

rails server -e production

但我在控制台中收到这些错误,并且正在加载一个没有 css 的丑陋页面:

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://10.20.200.199:3000/".
(index):1 Refused to execute script from 'http://10.20.200.199:3000/javascripts/application.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
(index):1 Refused to execute script from 'http://10.20.200.199:3000/logins/plugins.js?v=1' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

这发生在我们使用的所有脚本中。

谁能帮我看看这里可能出了什么问题。

提前致谢。

【问题讨论】:

    标签: ruby-on-rails production-environment


    【解决方案1】:

    使用生产环境预构建资产运行:rake assets:precompile

    所描述的错误表明浏览器请求静态资产;这些不是构建的(它们不是在生产中自动构建的 - 您应该在每次部署时构建它们),因此在它们的 URL 上找不到任何东西,而是呈现错误页面。因此,浏览器错误提示下载的 css 和 javascript 文件具有错误的 MIME 类型。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-25
      • 2016-03-12
      • 2021-05-22
      • 2014-03-24
      相关资源
      最近更新 更多