2

我只想将“excanvas.min.js”文件提供给 Internet Explorer 而不是其他浏览器

所以我在我的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' %>

但我收到以下错误(在生产中):

Completed 500 Internal Server Error in 3ms

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

强制 Rails 预编译文件时也会发生错误

# 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)

在“配置/生产.rb”中。我究竟做错了什么?

我可以做一个

//= require excanvas.min

application.js. 但这将包括每个浏览器的文件......

信息:我从 Rails 3.0 应用程序进行了更新。

4

2 回答 2

3

问题出在以下行

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

%W创建数组的快捷方式,项目之间需要用空格隔开。在您的情况下,您正在将字符串添加excanvas.min.js,other_file.css,even_anotherfile.js到预编译列表中。

所以只需按如下方式替换该行:

config.assets.precompile += %W(excanvas.min.js other_file.css even_anotherfile.js)
于 2012-03-16T19:06:11.290 回答
1

只需尝试为 line 和 . 添加 <%# %> 我认为它们将显示为评论。

或者

你可以这样做将 js.judge 浏览器与 js 并加载相应的 css 文件

于 2012-03-16T14:23:45.583 回答