A
A
Anton2016-08-29 20:53:17
Ruby on Rails
Anton, 2016-08-29 20:53:17

How to include script with condition (IE < 9) in Rails?

I add the following piece to the head:

<!--[if lt IE 9]>
<%= javascript_include_tag 'html5shiv.min', 'data-turbolinks-track': 'reload' %>
<![endif]-->

Rails is supposed to find a .coffee or .js file named html5shiv.min in the javascripts folder and output its /assets/ relative path in the template (at least that's how it works if included in an application.coffee file, for example). But that doesn't happen. Instead I get:
<!--[if lt IE 9]>
<script src="/javascripts/html5shiv.js" data-turbolinks-track="reload"></script>
<![endif]-->

Why is this happening and how then to place this script in the template with a condition for IE browsers?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Chronic 86, 2016-08-30
@hummingbird

Plug in gem html5shiv-js-rails and don't worry.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question