Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

IE6/7 CSS always rendered in Rails 3.2 #811

Closed
manafire opened this Issue · 5 comments

2 participants

@manafire

Rails 3.2.1 / Formtastic 2.1.0.rc

Following the instructions on "Stylesheet usage in Rails >= 3.1" results in the Internet Explorer stylesheets always being included and rendered, regardless of browser:

# app/assets/stylesheets/application.css
/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
 *
 * 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 formtastic
*/
# app/assets/stylesheets/ie6.css
/*= require formtastic_ie6 */
# app/assets/stylesheets/ie7.css
/*= require formtastic_ie7 */

HTML Output:

<link href="/assets/application.css?body=1" media="screen" rel="stylesheet" type="text/css" />
<link href="/assets/formtastic_ie6.css?body=1" media="screen" rel="stylesheet" type="text/css" />
<link href="/assets/ie6.css?body=1" media="screen" rel="stylesheet" type="text/css" />
<link href="/assets/formtastic_ie7.css?body=1" media="screen" rel="stylesheet" type="text/css" />
<link href="/assets/ie7.css?body=1" media="screen" rel="stylesheet" type="text/css" />
<link href="/assets/formtastic.css?body=1" media="screen" rel="stylesheet" type="text/css" />
    <!--[if IE 6]><link href="/assets/formtastic_ie6.css?body=1" media="screen" rel="stylesheet" type="text/css" />
<link href="/assets/ie6.css?body=1" media="screen" rel="stylesheet" type="text/css" /><![endif]-->
    <!--[if IE 7]><link href="/assets/formtastic_ie7.css?body=1" media="screen" rel="stylesheet" type="text/css" />
<link href="/assets/ie7.css?body=1" media="screen" rel="stylesheet" type="text/css" /><![endif]-->  
@justinfrench

This is an unfortunate side-effect of require_tree, and there's no way we can avoid it that I know of. Instead, require the specific style sheets you want specifically. I rarely want "everything".

@manafire

Thank you, Justin.

I removed require tree . to get the desired behaviour in development, but in production (on Heroku anyway) I received this error message:

Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError: ie6.css isn't precompiled. I had to add the following to config/production.rb:

  # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
  config.assets.precompile += %w( ie6.css ie7.css )

If you think this is not an isolated issue and may help others, I could add some concise content to the README under the Stylesheet usage in Rails >= 3.1 section (for my first ever open source contribution!).

@justinfrench justinfrench reopened this
@justinfrench
Owner

@onemanarmy Okay, have re-opened this so that I can explore for myself before deciding what's appropriate.

@justinfrench

@onemanarmy a doc patch would be great please!

@justinfrench

Merged in #830, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.