# Strange replace\_html image error going from 1.2.5 to 2.1.0

**URL:** <https://www.ruby-forum.com/t/strange-replace-html-image-error-going-from-1-2-5-to-2-1-0/158906>\
**Category:** Rails\
**Created:** [January 29, 2009, 9:46am UTC](https://www.ruby-forum.com/t/strange-replace-html-image-error-going-from-1-2-5-to-2-1-0/158906 "2009-01-29T09:46:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adeel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f4b2a3/32.png) [@adeel](https://www.ruby-forum.com/u/adeel)\
**Post date:** [January 29, 2009, 9:46am UTC](https://www.ruby-forum.com/t/strange-replace-html-image-error-going-from-1-2-5-to-2-1-0/158906/1 "2009-01-29T09:46:41Z")

</div>

Hi I’m tasked with upgrading an old app from 1.2.5 to 2.1.0.

There is a basic image rotation triggered by a link\_to\_remote button.  
The image gets rotated by Mini-Magick, saved, and then the div is  
updated on the page to show the rotated image. This works fine in  
1.2.5.

In 2.1.0 it does not. The image is being rotated and saved because a  
refresh shows a rotated image. Furthermore, if I make the  
image\_tag’s :title to be the image width (just to report something  
that should change for debugging) I see the new width of the rotated  
image when I hover over with the mouse. So it is being replaced but  
I’m not seeing it. Very odd since it works just fine in 1.2.5.

Here are the code snippets:

views/products/show.rhtml -  
\<%= link\_to\_remote image\_tag(“arrow\_turn\_right.png”), :url =\>  
{ :action =\> “rotate”, :id =\> @show\_pic } %\>

products\_controller.rb -  
def rotate  
@show\_pic = Asset.find\_by\_id(params[:id])  
@show\_pic.rotate(params[:dir])  
@pics = @show\_pic.product.images  
@show\_pic.save!  
render :update do |page|  
page[“product\_pic”].replace\_html :partial =\> ‘photo’  
page[“asset\_thumbs”].replace\_html :partial =\>  
‘pic’, :collection =\> @pics  
end  
end

\_photo.rhtml -  
\<%= image\_tag(@show\_pic.public\_filename(:large), :width =\> ‘300’, :alt  
=\> @show\_pic.product.title + string\_tags  
(@show\_pic.product.tags), :title =\> @show\_pic.width ) %\>

This does throw the following Ajax response in Firebug’s console:  
try {  
$(“product\_pic”).update("\u003Cimg alt=“acne " src=”/assets/  
0000/0001/IMG\_0086\_large.JPG?1233213603  
" title=“3264” width=“300” /\u003E\n\n");  
$(“asset\_thumbs”).update("\u003Cspan class=“thumb”\u003E\n\t\u003Ca  
href="/products/show?pic=1"\u003E  
\u003Cimg alt=“Img\_0086\_thumb” border=“1” height=“50” src="/  
assets/0000/0001/IMG\_0086\_thumb.JPG  
?1233213601" width=“50” /\u003E\u003C/a\u003E\n\u003C/span\u003E");  
} catch (e) { alert(‘RJS error:\n\n’ + e.toString()); alert(’$  
(“product\_pic”).update("\u003Cimg alt  
=\“acne \” src=\"/assets/0000/0001/IMG\_0086\_large.JPG?1233213603  
\" title=\“3264\” width=  
\“300\” /\u003E\n\n");\n$(“asset\_thumbs”).update("  
\u003Cspan class=\“thumb\”\u003E  
\n\t\u003Ca href=\"/products/show?pic=1\"\u003E\u003Cimg alt=\  
“Img\_0086\_thumb\” border=  
\“1\” height=\“50\” src=\"/assets/0000/0001/  
IMG\_0086\_thumb.JPG?1233213601\" width=\“50  
\” /\u003E\u003C/a\u003E\n\u003C/span\u003E");’); throw e }

Any ideas?

---

<div class="post-metadata">

**Author:** ![adeel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f4b2a3/32.png) [@adeel](https://www.ruby-forum.com/u/adeel)\
**Post date:** [January 29, 2009, 5:57pm UTC](https://www.ruby-forum.com/t/strange-replace-html-image-error-going-from-1-2-5-to-2-1-0/158906/2 "2009-01-29T17:57:31Z")

</div>

Hi Adeel,

On Jan 29, 9:45 am, adeel [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi I’m tasked with upgrading an old app from 1.2.5 to 2.1.0.
> 
> There is a basic image rotation triggered by a link\_to\_remote button.  
> The image gets rotated by Mini-Magick, saved, and then the div is  
> updated on the page to show the rotated image. This works fine in  
> 1.2.5.  
> …
> 
> Any ideas?

Did you run a rake rails:update:scripts ?  
I suspect the prototype files have changed and trouble you now.

About JS debugging, the error console (CMD-SHIFT-J on a Mac) will  
give you a lot more information than the Firebug console usually does  
(unless you configured it to do so).

ciao, tom

–  
Thomas R. “TomK32” Koll \<\> [http://ananasblau.com](http://ananasblau.com)  
just a geek trying to change the world  
[TomK32 (Thomas R. Koll) · GitHub](http://github.com/TomK32)

---

<div class="post-metadata">

**Author:** ![adeel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f4b2a3/32.png) [@adeel](https://www.ruby-forum.com/u/adeel)\
**Post date:** [January 29, 2009, 6:49pm UTC](https://www.ruby-forum.com/t/strange-replace-html-image-error-going-from-1-2-5-to-2-1-0/158906/3 "2009-01-29T18:49:24Z")

</div>

I just ran rake rails:update:scripts but to no avail. It updated a  
couple of scripts unrelated to prototype.  
It still does not update the rotated image.

When I open the Firefox error console as you suggested, and I am  
seeing:  
Warning: Empty string passed to getElementById().  
However this occurs even under 1.2.5 when it’s working so I think this  
is a red herring.

Did something else change in Rails 2 for replacing objects?
