css使用stylesheet_link_tag重复

时间:2011-09-23 13:33:51

标签: ruby-on-rails ruby-on-rails-3 helper stylesheet-link-tag

我正在尝试在rails3应用程序中订购我的样式表,但是我遇到了使用* stylesheet_link_tag *帮助程序重复自己的行的问题。

在app / views / layouts / 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" />

app / assets / stylesheets / folder的内容:

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

使用* javascript_include_tag * helper会出现同样的问题,我认为两者都可以相关。

1 个答案:

答案 0 :(得分: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 .