簡體   English   中英

資產rails 3.1在預編譯nginx + unicorn后未加載

[英]assets rails 3.1 not load after precompile nginx + unicorn

我正在嘗試在生產環境中預編譯資產。 但在預編譯后,應用程序找不到圖像文件,javascripts文件,css文件等。

我運行這個命令:

RAILS_ENV=production rake assets:precompile

我得到這個結果:

/home/hyperrjas/.rvm/rubies/ruby-1.9.2-p318/bin/ruby /home/hyperrjas/.rvm/gems/ruby-1.9.2-p318/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
/home/hyperrjas/.rvm/rubies/ruby-1.9.2-p318/bin/ruby /home/hyperrjas/.rvm/gems/ruby-1.9.2-p318/bin/rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets

然后我嘗試重新加載頁面,我看到這個:

在此輸入圖像描述

我正在使用nginx +獨角獸。

為什么應用程序找不到資產,圖像,CSS,JavaScript ...

編輯**

我從application.html.erb加載我的資產布局:

<%= stylesheet_link_tag    "application" %>
  <%= javascript_include_tag "application" %>

我在我的nginx.conf中有這個在服務器{}

location ~ ^/(assets)/  {
                          root ~/mydomain.com/current/public;
                          gzip_static on; # to serve pre-gzipped version
                          expires max;
                          add_header  Cache-Control public;
                         }

謝謝

問題得到解決:D:

錯誤發生在nginx.conf中:

location ~ ^/(assets)/  {
                         root ~/mydomain.com/current/public;
                         gzip_static on; # to serve pre-gzipped version
                         expires max;
                         add_header  Cache-Control public;
                        }

root到資產的路徑很糟糕,正確的形式是:

 location ~ ^/(assets)/  {
                            root /home/hyperrjas/mydomain.com/current/public;
                            gzip_static on; # to serve pre-gzipped version
                            expires max;
                            add_header  Cache-Control public;
                           }

謝謝!

第一,

你可以檢查 - Manifest文件和指令app/assets/javascripts/application.js它應該是

// ...
//= require jquery
//= require jquery_ujs
//= require_tree

app/assets/stylesheets/application.css

/* ...
*= require_self
*= require_tree .
*/

檢查,在您的應用程序中的config / environment / production.rb中的設置下面應該是真的

config.assets.compile = true

如果您想要資產URL的摘要,如果它是false,則使其低於true。

config.assets.digest = true

很少有參考鏈接

http://mrjaba.posterous.com/rails-31-asset-pipeline-with-nginx-and-passen

http://guides.rubyonrails.org/asset_pipeline.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM