希望有人可以幫助我,因爲我瘋狂閱讀/嘗試一切,以獲得我的CSS文件加載生產,但他們要麼不顯示或我得到一個404錯誤。Rails 3.2資產管道+自定義主題+引導
我的3.2 RoR應用程序正在使用購買的主題和引導程序的組合。當然,一切都看起來很棒,但一旦我推到產品上,沒有什麼能正常工作。
此外,我有2個佈局,application.html.erb和homepage.html.erb。 Application.html.erb調用一個額外的CSS,如下所述。
我在我的應用程序/資產/樣式表目錄中的以下內容:
stylesheets
+compiled
--theme.css #references bootstrap/bootstrap.min.css
--custom_theme.css #additional CSS used in application.html.erb
+vendor
--animate.css
--brankic.css
+bootstrap
--bootstrap.min.css
application.css
inbox.css
在我application.html.erb佈局我明確地調用下面的CSS:
<%= stylesheet_link_tag 'compiled/theme.css', 'vendor/brankic.css', 'vendor/animate.css', 'compiled/custom_theme.css', 'inbox.css' %>
在主頁。 html.erb佈局我明確地調用以下CSS:
<%= stylesheet_link_tag 'compiled/theme.css', 'vendor/brankic.css', 'vendor/animate.css', 'inbox.css' %>
我試過使用application.cs s,其中* = require_tree。但是這會吸引所有的東西,並且從主頁佈局我不需要custom_theme。如果我創建homepage.css並省略custom_theme,則仍需要放入* = require_tree。因爲在theme.css中有對目錄中其他文件的引用。
最後,我試過在我的config/env/prod文件中顯式預編譯CSS,但是這並沒有引用引用的css文件。
編輯
每麥克的建議,我已經添加了以下到我的配置/ ENV/PROD文件:
config.assets.precompile += ['bootstrap/bootstrap.min.css','compiled/theme.css', 'vendor/brankic.css', 'vendor/animate.css', 'se2b_custom.css', 'inbox.css']
如上所述,我還是直接調用每一個CSS和仍然收到每個生產中的404錯誤。
使用我的主頁佈局查看頁面的源代碼,這是什麼所示:
<link href="/assets/bootstrap/bootstrap.min.css?body=1" media="screen" rel="stylesheet" type="text/css" />
<link href="/assets/compiled/theme.css?body=1" media="screen" rel="stylesheet" type="text/css" />
<link href="/assets/vendor/brankic.css?body=1" media="screen" rel="stylesheet" type="text/css" />
<link href="/assets/vendor/animate.css?body=1" media="screen" rel="stylesheet" type="text/css" />
<link href="/assets/inbox.css?body=1" media="screen" rel="stylesheet" type="text/css" />
點擊在404
謝謝。我認爲這將包括那些也引用另一個CSS內?怎麼樣在CSS內調用字體? – user464180 2015-02-06 13:01:59
再次感謝邁克。我已經使用您的建議進行了上述編輯,但仍然收到404錯誤。 – user464180 2015-02-06 14:39:50
看到我的更新:) – mkralla11 2015-02-06 14:51:23