2012-01-09 44 views
9

我已經完成了這個在我的Leopard網絡服務器上使用生產的姐妹Rails 3.1應用程序。所以我沒有想到會失去這個應用程序的部署。我已經得到乘客認識的應用程序,但我得到'[GET /]錯誤在Apache中的錯誤。環顧四周我想我可以得到這個在webrick中運行,看看我是否可以找出問題。鐵軌生產的'CSS是不是預編譯'

束EXEC耙資產:預編譯RAILS_ENV =生產

但是當我加載本地主機:3000我碰到一個「藍圖/ screen.css不預編譯」

我開始比較妹妹之間的差異應用程序並找不到它們。這裏是他們分享的一些關鍵代碼:

<%= stylesheet_link_tag "application" %> 
    <%= javascript_include_tag "application" %> #in app/views/layouts/application.html.erb 

config/environments/production.rb 
config.consider_all_requests_local  = false 
    config.action_controller.perform_caching = true 
config.serve_static_assets = false 
config.assets.precompile += %w(search.js) 
    config.assets.precompile += %w(blueprint/screen.css blueprint/print.css) 
    config.assets.precompile += %w(*.css *.js) 

這發生在3.1.0和3.1.3,我可以確認預編譯發生在藍圖目錄上。我可以忽略什麼?,山姆

+0

我遇到了一個「gotcha」,其中逗號分隔了'%w()'中的項目,這些逗號成爲數組項的一部分而不是將它們分開。例如。 '%w(blueprint/screen.css,blueprint/print.css)#=> ['blueprint/screen.css','blueprint/print.css']' – 2015-07-05 23:12:41

回答

12

你有沒有單獨嘗試過?

config.assets.precompile += %w(blueprint/screen.css) 
config.assets.precompile += %w(blueprint/print.css) 

然後運行:

bundle exec rake assets:precompile RAILS_ENV=production 

這應該修復它。

+0

它應該有。我是這樣的:config.assets.precompile + =%w(blueprint/screen.css blueprint/print.css) – sam452 2012-01-28 20:26:12

+1

只是好奇,爲什麼要將預編譯數組附加到單獨的行中解決他的問題? – 2015-07-05 23:07:20

9

您可以在生產環境中將assets.compile設置爲true,以便在文件丟失時回退到資產管道。

# config/environments/production.rb 
# ... 
# Fallback to assets pipeline if a precompiled asset is missed 
    config.assets.compile = true 
+7

小心,這可以殺死性能。 – orourkedd 2014-04-07 19:42:24

+0

這確實修復了_symptom_,但它隱藏了_problem_,它可以修復,應該修復。 – 2015-07-05 23:09:15