0

我想在rails3應用程序中訂購我的樣式表,但是我有一個使用* stylesheet_link_tag * helper重複自己的行的問題。css重複使用stylesheet_link_tag

在應用程序/視圖/佈局/ application.html.erb

<%= stylesheet_link_tag :reset, :application, :event_calendar, :cache => false %> 

在產生源代碼:應用程序/資產/樣式表/文件夾的

<link href="/assets/reset.css?body=1" media="screen" rel="stylesheet" type="text/css" /> 
<link href="/assets/application.css?body=1" media="screen" rel="stylesheet" type="text/css" /> 
<link href="/assets/event_calendar.css?body=1" media="screen" rel="stylesheet" type="text/css" /> 
<link href="/assets/reset.css?body=1" media="screen" rel="stylesheet" type="text/css" /> 
<link href="/assets/event_calendar.css?body=1" media="screen" rel="stylesheet" type="text/css" /> 

內容:

calendar (master *)$ ls app/assets/stylesheets/ 
application.css  event_calendar.css reset.css 

使用* javascript_include_tag * helper會出現同樣的問題,我認爲兩者都有關係。

回答

2

如果您正在使用的管道資產只需要包括application.css因爲裏面應該有線條狀...

/* 
* This is a manifest file that'll automatically include all the stylesheets available in this directory 
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at 
* the top of the compiled file, but it's generally better to create a new file per style scope. 
*= require_self 
*= require_tree . 
*/ 

不要被實際上它註釋掉所迷惑,這將是因爲require_tree .命令會自動將所有文件包含在同一個目錄中。

只要把...

<%= stylesheet_link_tag :application, :cache => false %> 

可以內application.css指定的順序,如果你需要你的reset.css先來

*= require reset 
*= require_self 
*= require_tree .