我正在开发 Rails 3.1 应用程序,它包含第三方 JS 日历选择器 (jsDatePick)。 jsDatePick 有一大堆图像,位于 images/calendar/img/中。
运行 rake asset:precompile 会预编译它们,但库仍然在 images/calendar/img 中查找图像(而不是 asset/calendar/img)。我可以将目录更改为 asset/calendar/img,但它不会附加指纹哈希。
关于如何解决这样的问题的想法?
以下是与此 JS 库一起使用的一些 CSS 示例:
.JsDatePickBox .boxLeftWall .leftTopCorner{ margin:0; padding:0; width:7px; height:8px; background:url(/assets/calendar/img/boxTopLeftCorner.png) left top no-repeat; overflow:hidden; }
.JsDatePickBox .boxLeftWall .leftBottomCorner{ margin:0; padding:0; width:7px; height:8px; background:url(/assets/calendar/img/boxBottomLeftCorner.png) left top no-repeat; overflow:hidden; }
.JsDatePickBox .boxLeftWall .leftWall{ margin:0; padding:0; width:7px; background:url(/assets/calendar/img/boxSideWallPx.gif) #ffffff left top repeat-y; overflow:hidden; }
虽然我在这里确实看到了一个问题(应该使用 Assets 标签,因为如果没有指纹哈希,这些图像不存在于 Assets 文件夹中),但我专门寻找的一些图像不在以下任何 CSS 文件中应用程序。我现在正在寻找确定他们被调用的位置。
看起来其他图像是通过 JavaScript 应用的。这是一个例子:
if (parseInt(aDayDiv.getAttribute("isToday")) == 1){
this.setC(aDayDiv, "dayDownToday");
aDayDiv.style.background = "url(" + this.oConfiguration.imgPath + this.oConfiguration.cellColorScheme + "_dayDown.gif) left top no-repeat";
} else {
this.setC(aDayDiv, "dayDown");
aDayDiv.style.background = "url(" + this.oConfiguration.imgPath + this.oConfiguration.cellColorScheme + "_dayDown.gif) left top no-repeat";
}
oConfiguration.imgPath 定义如下:
g_jsDatePickImagePath = "/assets/calendar/img/";
this.oConfiguration.imgPath = (g_jsDatePickImagePath.length != null) ? g_jsDatePickImagePath : "/images/calendar/img/";
感谢您的帮助。
最佳答案
答案是升级到 Rails 3.1.1+(我升级到 Rails 3.1.2),Rails 运行 rake asset:precompile:nondigest 解决了这个问题,这会导致 Assets 的未消化版本。
关于ruby-on-rails-3.1 - Rails 3.1 Assets 管道和第三方 JS 日历,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9285254/