Rails 3引擎和静态资产 [英] Rails 3 Engine & Static assets

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

问题描述

我正在构建捆绑为gem(gmaps4rails)的引擎.我在我的rails应用程序的/public中复制了引擎的/public.

I'm building an engine I've bundled as a gem (gmaps4rails). I copied the /public of my engine in the /public of my rails app.

一切在开发中都可以正常运行,但在生产中却无法正常工作:似乎没有找到(我的引擎和我的主应用程序的)静态资产.

Everything works fine in development but fails to work in production: it appears static assets (of my engine & my main app) aren't found.

日志告诉以下内容(仅是摘要):

The logs tell the following (just an abstract):

Started GET "/javascripts/application.js?1286294679" for 127.0.0.1 at Wed Nov 24 00:22:20 +0100 2010

ActionController::RoutingError (No route matches "/javascripts/application.js"):


Rendered /Users/me/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.1ms)


Started GET "/stylesheets/gmaps4rails.css?1290554221" for 127.0.0.1 at Wed Nov 24 00:22:20 +0100 2010

ActionController::RoutingError (No route matches "/stylesheets/gmaps4rails.css"):

我已经做了几件事:

  1. 在我的应用的production.rb中,我设置了:

  1. in my app's production.rb, I set:

config.serve_static_assets = true

config.serve_static_assets = true

这可以解决问题,但不够优雅,我想将其保留为false并在引擎中添加配置:)

This Solves the problem but is not elegant enough, I'd like to keep it to false and add configuration in the engine :)

我遵循了此处的建议.没有成功. p>

I followed the advice here without success.

推荐答案

出于性能原因,在生产模式下禁用了静态资产服务.您的网络服务器应配置为提供这些资产.

For performance reason, static assets serving is disabled in production mode. Your webserver should be configured to serve theses assets.

请参见以下讨论您正在使用nginx作为网络服务器.

Look at this discussion if your are using nginx as a webserver.

这篇关于Rails 3引擎和静态资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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