开发者

CSS lines are repeating using stylesheet_link_tag

I'm trying to order my stylesheets in a rails3 app, but I've got an issue with the lines repeating themselves using the *stylesheet_link_tag* helper.

In app/views/layouts/application.html.erb

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

In produced source code:

<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" />

Content of app/assets/stylesheets/ folder:

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

The same kind of problem 开发者_JS百科appears using *javascript_include_tag* helper, I think both can be related.


If you're using the asset pipeline you only need include application.css as inside that there should be lines like...

/*
 * 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 . 
*/

Don't be fooled by the fact its commented out, this will be processed and will automatically include all the files in the same directory because of the require_tree . command.

Just put...

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

You can specify the order within application.css if you need your reset.css to come first

*= require reset
*= require_self
*= require_tree . 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜