css& js不在rails生产模式下工作

时间:2014-06-12 05:54:08

标签: javascript css ruby-on-rails ruby

当我做的时候

thin start --ssl -p 4000 -e production

启动我的服务器所有内容都可见,但没有任何css& js不工作, 我检查了很多文件和以下事情可以做,但没有任何事情发生

 config.serve_static_assets = true  
 config.assets.compile = true

 config.assets.precompile += %w(
shopqi_application.js shopqi_wiki_application.js admin_application.js checkout_application.js active_admin.js
layout_application.css layout_admin.css layout_admin_print.css layout_shopqi.css
shopqi_ie-signup.css layout_shopqi_theme.css active_admin.css layout_shopqi_wiki.css
layout_checkout.css admin/layout_doorkeeper_authorization.css
ie6.css ie-admin.css ie7.css ie-checkout.css ie.css ie-themes.css ie7-themes.css DD_belatedPNG_0.0.8a-min.js)  

我也做

RAILS_ENV=production rake assets:precompile  

手动清理公共/资产,但没有任何事情发生。

2 个答案:

答案 0 :(得分:3)

有关assets pipeline

的详细信息

production.rb: -

config.serve_static_assets = false
#config.assets.precompile += %w(shopqi_application.js shopqi_wiki_application.js admin_application.js checkout_application.js active_admin.js layout_application.css layout_admin.css layout_admin_print.css layout_shopqi.css shopqi_ie-signup.css layout_shopqi_theme.css active_admin.css layout_shopqi_wiki.css layout_checkout.css admin/layout_doorkeeper_authorization.css ie6.css ie-admin.css ie7.css ie-checkout.css ie.css ie-themes.css ie7-themes.css DD_belatedPNG_0.0.8a-min.js)  

application.rb的{​​{1}}中添加此内容: -

config/

config.assets.initialize_on_precompile=false 中添加以下行: -

application.js

//= require shopqi_application //= require shopqi_wiki_application //= require admin_application //= require checkout_application //= require active_admin //= require DD_belatedPNG_0.0.8a-min 中添加以下行: -

application.css

然后: -

*= require layout_application
*= require layout_admin
*= require layout_admin_print
*= require layout_shopqi
*= require shopqi_ie-signup
*= require layout_shopqi_theme
*= require active_admin
*= require layout_shopqi_wiki
*= require layout_checkout
*= require admin/layout_doorkeeper_authorization
*= require ie6
*= require ie-admin
*= require ie7
*= require ie-checkout
*= require ie
*= require ie-themes
*= ie7-themes

启动服务器: -

bundle exec rake assets:precompile

启动服务器,使其在关闭终端后始终运行: -

thin start -p 4000 -e production

答案 1 :(得分:1)

Try->

RAILS_ENV=production bundle exec rake assets:precompile