0

I'm using an script to detect internet explorer and display a message. It is not referenced in application.js and I don't want to have it there because it is for one specific page of a controller.

Following this article (ยง3) http://blog.55minutes.com/2012/02/untangling-the-rails-asset-pipeline-part-3-configuration/, I added in my config/development.rb file the following:

config.assets.precompile += ['iealert.js']

Now in my application layout, at the bottom, I have (using haml)

/ [if IE]
      = javascript_include_tag "iealert"

The script is included in 2 places, at the bottom, but also in the header (with javascript_include_tag "application", "data-turbolinks-track" => true), therefore all browsers get the alert since the header inclusion is automatic and not conditional.

What am I doing wrong ?

Arnaud
  • 17,268
  • 9
  • 65
  • 83

1 Answers1

1

Maybe something like this:

<%= javascript_include_tag :defaults %>
<!--[if IE]><%= javascript_include_tag "excanvas.min" %><![endif]-->

Rails 3 Conditional Inclusion of Javascript files

Could be wrong though :)

Community
  • 1
  • 1
Richard Peck
  • 76,116
  • 9
  • 93
  • 147