2011-12-13 224 views
0

我正在使用rails 3應用程序並嘗試將其部署到生產環境中。 我正在使用capistrano來部署我的應用程序並將其配置爲在update_code任務之後預編譯資產。Rails 3.1資產預編譯

事情是一切工作正常,當我部署應用程序。 通過下面的服務器生產日誌,我看到這一點:

Compiled application.js (6ms) (pid 7552) 
Compiled jquery.js (4ms) (pid 7552) 
Compiled jquery_ujs.js (0ms) (pid 7552) 
Compiled home.js (94ms) (pid 7552) 
Compiled libs/dd_belatedpng.js (0ms) (pid 7552) 
Compiled libs/modernizr-1.7.min.js (0ms) (pid 7552) 
Compiled plugins.js (0ms) (pid 7552) 
Compiled script.js (0ms) (pid 7552) 
Compiled user_sessions.js (93ms) (pid 7552) 
Compiled users.js (92ms) (pid 7552) 
Compiled application.css (3ms) (pid 7552) 
Compiled handheld.css (0ms) (pid 7552) 
Compiled home.css (55ms) (pid 7552) 
Compiled style.css (0ms) (pid 7552) 
Compiled user_sessions.css (1ms) (pid 7552) 
Compiled users.css (0ms) (pid 7552) 
Compiled application.js (6ms) (pid 7541) 
Compiled jquery.js (4ms) (pid 7541) 
Compiled jquery_ujs.js (0ms) (pid 7541) 
Compiled home.js (95ms) (pid 7541) 
Compiled libs/dd_belatedpng.js (0ms) (pid 7541) 
Compiled libs/modernizr-1.7.min.js (0ms) (pid 7541) 
Compiled plugins.js (0ms) (pid 7541) 
Compiled script.js (0ms) (pid 7541) 
Compiled user_sessions.js (93ms) (pid 7541) 
Compiled users.js (94ms) (pid 7541) 
Compiled application.css (2ms) (pid 7541) 
Compiled handheld.css (0ms) (pid 7541) 
Compiled home.css (1ms) (pid 7541) 
Compiled style.css (0ms) (pid 7541) 
Compiled user_sessions.css (0ms) (pid 7541) 
Compiled users.css (0ms) (pid 7541) 

但是,如果我嘗試在瀏覽器中顯示的主網頁,我得到這個:

ActionView::Template::Error (style.css isn't precompiled): 
    14: 
    15:  %link{:rel => "shortcut icon", :href => "/favicon.ico" } 
    16:  %link{:rel => "apple-touch-icon", :href => "/apple-touch-icon.png"} 
    17:  = stylesheet_link_tag "style" 
    18:  = javascript_include_tag "libs/modernizr-1.7.min" 
    19:  = javascript_include_tag "application" 
    20: 
    app/views/layouts/application.html.haml:17:in   `_app_views_layouts_application_html_haml__1713356285_69878424198520' 

我只是不明白是怎麼服務器能夠告訴我資產已經編譯,並且在它告訴我實際上文件沒有被編譯之後。

有沒有人遇到過這種問題?

感謝您的幫助。

+0

你有沒有`restart`應用服務器? – 2011-12-13 21:53:58

+0

嗨Nizzle先生,我嘗試了幾次後更新完成重新啓動Apache。在預編譯之後,我也有這個任務 - 在「資產:預編譯」,「乘客:重啓」之後 - 它觸摸了tmp/restart.txt – Elendir 2011-12-14 10:13:49

回答

1

一種解決方法是告訴生產環境不檢查在config/environments/production.rb預編譯並設置行:

config.assets.compile = false 

config.assets.compile = true 

重新啓動服務器,然後你應該檢查HALM正在尋找style.css應該是assets/style.css


UPDATE

這裏的另一種選擇

告訴你config/environments/production.rb編譯恰好文件,以確保它被編譯。

config.assets.precompile += %w(style.css)

看到這對https://stackoverflow.com/a/7541958/295228