2

I want to server the 'excanvas.min.js' file only to the Internet Explorer and not to other browsers.

So I did in my application.html.erb:

<!--[if lt IE 9]>
<%= javascript_include_tag 'excanvas.min'
# Excanvas for use of Canvas in IE up to version 8
%>
<![endif]-->
<%= javascript_include_tag 'application' %>

But I get the following error (in production):

Completed 500 Internal Server Error in 3ms

ActionView::Template::Error (excanvas.min.js isn't precompiled)

The error also happens when forcing Rails to precompile the file with

# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false
config.assets.precompile += %W(excanvas.min.js,other_file.css,even_anotherfile.js)

in 'config/production.rb'. What am I doing wrong?

I could do a

//= require excanvas.min

in the application.js. But that would include the file for every browser...

Info: I made an update from an Rails 3.0-Application.

Sandro L
  • 1,140
  • 18
  • 32

2 Answers2

3

The problem is in the following line

config.assets.precompile += %W(excanvas.min.js,other_file.css,even_anotherfile.js)

the %W is a shortcut for creating an array, and the items need to be separated by a space. In your case you are adding the string excanvas.min.js,other_file.css,even_anotherfile.js to the precompile list.

So just replace the line as follows:

config.assets.precompile += %W(excanvas.min.js other_file.css even_anotherfile.js)
Wolfgang
  • 4,865
  • 2
  • 29
  • 29
1

just try to add <%# %> for line and . i think they will be displayed as comment.

OR

you can do that will js.judge the browser with js and load the corresponding css file

hlcfan
  • 313
  • 1
  • 2
  • 10
  • That is not usefull. I need the javascripts, so uncommenting them is not an option. Wolfgangs answer helped. – Sandro L Mar 19 '12 at 07:40