In Prototype 1.6, find function can not generate right URL. The final
URL is like this:
http://localhost:3000/books/:id.json?id=1
This problem is because the implementation of _interpolate function.
In _interpolate function, the for...in loop can not find id param,
this is because Prototype has modified Object's function, this
modifition has bad effect to for...in loop. To solve this problem, we
must use Prototype's each function to do the same thing.
I modified _interpolate function like this:
_interpolate: function(string, params) {
var result = string;
if (params) {
params.each(function(pair) {
var re = new RegExp(":" + pair.key, "g");
if (result.match(re)) {
result = result.replace(re, pair.value);
params.unset(pair.key);
}
});
}
return result;
},
This time it works, the final URL is like this:
http://localhost:3000/books/1.json?id=1
I use Jester 1.5, Prototype 1.6.0.1, Rails 2.0.1 and Firefox 2.0.0.11
on Windows 2000 Professional SP4.