# Attachment\_fu show unsaved images?

**URL:** <https://www.ruby-forum.com/t/attachment-fu-show-unsaved-images/147353>\
**Category:** Rails\
**Created:** [August 31, 2008, 10:44pm UTC](https://www.ruby-forum.com/t/attachment-fu-show-unsaved-images/147353 "2008-08-31T22:44:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrewdon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9bcb4/32.png) [@andrewdon](https://www.ruby-forum.com/u/andrewdon)\
**Post date:** [August 31, 2008, 10:44pm UTC](https://www.ruby-forum.com/t/attachment-fu-show-unsaved-images/147353/1 "2008-08-31T22:44:55Z")

</div>

Is there any established way to display an image uploaded by  
attachment\_fu before the model with which it is associated is actually  
saved? For instance, I have an Artwork model which has many images. I’d  
like to allow image uploads on the new artwork form to be displayed  
after they are uploaded but before the artwork is saved.

Thanks

---

<div class="post-metadata">

**Author:** ![andrewdon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9bcb4/32.png) [@andrewdon](https://www.ruby-forum.com/u/andrewdon)\
**Post date:** [September 1, 2008, 4:57am UTC](https://www.ruby-forum.com/t/attachment-fu-show-unsaved-images/147353/2 "2008-09-01T04:57:09Z")

</div>

I’ve figured out some of what I want to do here, so I can be more  
specific:

This create action adds each uploaded Image, then creates a thumnail of  
each and stores it in the @temp\_thumb\_data array.

def create  
@artwork = @current\_user.artworks.new params[:artwork]  
params[:image\_data].each do |file|  
@artwork.images \<\< Image.new( :uploaded\_data =\> file ) if file.size

> 0  
> end unless not params[:image\_data]

@temp\_thumb\_data = []  
@artwork.images.each do |image|  
image.with\_image do |img|  
@temp\_thumb\_data \<\< img.thumbnail(100, 100).to\_blob  
end  
end  
…

However it is stored as an encoded string and can thus not simply be  
displayed. The normal method would be to use send\_data in another  
action, but I can’t do that here because the uploaded file is not being  
persisted and would not be available to the other action.

Any ideas?
