Ruby on rails + ajax + iframe image uploader

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

you should use a plugin called responds_to_parent :
http://agilewebdevelopment.com/plugins/responds_to_parent

On Nov 9, 3:34 am, Ghee wooi Ong [email protected]