# Ruby on rails + ajax + iframe image uploader

**URL:** <https://www.ruby-forum.com/t/ruby-on-rails-ajax-iframe-image-uploader/119674>\
**Category:** Rails\
**Created:** [November 9, 2007, 3:34am UTC](https://www.ruby-forum.com/t/ruby-on-rails-ajax-iframe-image-uploader/119674 "2007-11-09T03:34:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ghee\_wooi\_O](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f475e1/32.png) [@Ghee\_wooi\_O](https://www.ruby-forum.com/u/Ghee_wooi_O)\
**Post date:** [November 9, 2007, 3:34am UTC](https://www.ruby-forum.com/t/ruby-on-rails-ajax-iframe-image-uploader/119674/1 "2007-11-09T03:34:14Z")

</div>

hi,

I write a page that contain following function:

this site contain a html file upload control, which allow user to upload  
image only.

once the image had been uploaded, it will automatic display on the  
current page without refresh entire page.

when the image is saved, it will return javascript that embed in a  
iframe (which is also in my current page) that can load the image into  
my page ( say in

 element).

however, when upload an invalid file (I use attachment\_fu’s  
validate\_as\_attachment), the error result is return to iframe due to  
iframe is the target of form ( form id=“uploader” target=“my\_iframe”\> )

I wanna display the error message, but the code is stop after entire  
page with error is return to my iframe.

my code look this :

def create  
begin  
#success code logic  
rescue  
render :action=\>‘new’ #return entire template in iframe,  
end  
end

is that any way to display in error in main page?

Is that any possible solution for it ?

kiwi

---

<div class="post-metadata">

**Author:** ![Ghee\_wooi\_O](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f475e1/32.png) [@Ghee\_wooi\_O](https://www.ruby-forum.com/u/Ghee_wooi_O)\
**Post date:** [November 9, 2007, 11:05pm UTC](https://www.ruby-forum.com/t/ruby-on-rails-ajax-iframe-image-uploader/119674/2 "2007-11-09T23:05:32Z")

</div>

you should use a plugin called responds\_to\_parent :  
[http://agilewebdevelopment.com/plugins/responds\_to\_parent](http://agilewebdevelopment.com/plugins/responds_to_parent)

On Nov 9, 3:34 am, Ghee wooi Ong [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
