机车生产资产 [英] Locomotivecms Assets in Production

查看:110
本文介绍了机车生产资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在locomotivecms google网上论坛中问过这个问题,但尚未得到任何有用的答复.所以,在这里尝试.我觉得这个问题不仅是铁轨问题,而且与机车引擎的实现方式有关.

I have asked this question in the locomotivecms google groups, but haven't gotten any useful response yet. So, trying out here. I have a feeling the issue is not just a rails issue but has something to do with how the locomotivecms engine is implemented.

我按照此处的说明安装了locomotivecms应用程序- http://doc.locomotivecms.com/guides/get-started/install-engine

I installed the locomotivecms app as per the instructions here - http://doc.locomotivecms.com/guides/get-started/install-engine

该应用在开发模式下运行良好.

The app runs fine in development mode.

然后我预编译资产并以生产模式(bundle exec unicorn_rails -E production)启动它.现在,当我在浏览器中打开应用程序时,不会呈现样式表.我已经检查了公共/资产,并且在那里存在浏览器请求的指纹样式表.但是它不能正确渲染. chrome视图资源显示了以下内容:

I then precompiled the assets and started it in production mode (bundle exec unicorn_rails -E production). Now when I open the app in the browser, the stylesheets are not rendered. I have checked the public/assets and the fingerprinted stylesheet requested by the browser is present there. Yet it is not rendered correctly. This is what the chrome view resources shows:

样式表似乎包含html.如果我从public/assets文件夹中打开它,则它包含CSS.我认为机车正在拦截请求,并以某种方式不返回CSS.机车是开源的,其代码在github- https://github.com/locomotivecms/engine .

It looks as if the stylesheet contains html. If I open it from the public/assets folder it contains css. I think Locomotive is intercepting the request and somehow not returning the css. Locomotive is open source, their code is on github - https://github.com/locomotivecms/engine.

推荐答案

问题不是Locomotivecms引起的,这是我不知道的Rails问题.我在production.rb中有以下内容:

The problem was not with Locomotivecms, it was a rails thing that I did not know about. I had following in production.rb:

config.serve_static_assets = false

config.serve_static_assets = false

如果您正在生产中的Nginx或Apache中运行您的应用程序,则此设置正确.在这种情况下,它们将管理公共资产.但是,如果您仅在生产中的Rails服务器(例如独角兽,webbrick,thin等)上运行应用程序,则需要将此设置设置为true,以便Rails服务器可以从公用文件夹中提供资产.我将其设置为true,启动服务器(bundle exec unicorn_rails -E production)资产运行正常.

This setting is right if you are running your app in Nginx or Apache in production. In which case they server the public assets. But if you are running your app on simply a rails server in production, like unicorn, webbrick, thin etc. then you need to set this setting to true in order for the rails server to serve assets from public folder. I set this to true, started the server (bundle exec unicorn_rails -E production) the assets were served fine.

有关config.serve_static_assets的更多解释可以在这里找到: http://guides.rubyonrails.org/configuring .html

More explanation on config.serve_static_assets can be found here: http://guides.rubyonrails.org/configuring.html

这篇关于机车生产资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆