【发布时间】:2013-08-20 05:28:00
【问题描述】:
我正在运行 rails 3.2.11。
我正在使用一个 JS 插件(epiceditor),它要求我拥有几个 js 调用的静态文件。在开发中,我可以通过资产管道轻松访问文件。
在生产中,我已经将 serve 静态资产设置为 true,但它仍然没有显示出来。
config.serve_static_assets = true
文件保存在 assets 目录中:
- assets
- stylesheets
- epiceditor
在开发中,它可以工作:
在生产中,它不起作用:
正在执行的JS代码插入css:
function _insertCSSLink(path, context, id) {
id = id || '';
var headID = context.getElementsByTagName("head")[0]
, cssNode = context.createElement('link');
_applyAttrs(cssNode, {
type: 'text/css'
, id: id
, rel: 'stylesheet'
, href: path
, name: path
, media: 'screen'
});
headID.appendChild(cssNode);
}
我在控制台中看到的:
Resource interpreted as Stylesheet but transferred with MIME type application/json: "http://www.fulfilled.in/assets/epiceditor/epiceditor.css". application.js:30
(anonymous function)
【问题讨论】:
-
您使用的是哪个网络服务器?这是发生在所有资产上还是仅发生在某些特定资产上?您是否尝试过预编译资产?您必须运行 RAILS_ENV=production bundle exec rake assets:precompile。
标签: ruby-on-rails ruby-on-rails-3.2 asset-pipeline pre-compilation