# Previewing a post with an attachment\_fu image

**URL:** <https://www.ruby-forum.com/t/previewing-a-post-with-an-attachment-fu-image/127210>\
**Category:** Rails\
**Created:** [January 26, 2008, 7:53am UTC](https://www.ruby-forum.com/t/previewing-a-post-with-an-attachment-fu-image/127210 "2008-01-26T07:53:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubynuby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ba9def/32.png) [@rubynuby](https://www.ruby-forum.com/u/rubynuby)\
**Post date:** [January 26, 2008, 7:53am UTC](https://www.ruby-forum.com/t/previewing-a-post-with-an-attachment-fu-image/127210/1 "2008-01-26T07:53:40Z")

</div>

I want to allow the user to preview the posts they’re making. Easy  
enough to do with text and a single model. However, now I want to  
allow posting of (multiple) attachments per post. My models:

class Post \< ActiveRecord::Base  
has\_many :attachments  
…  
end

class Attachment \< ActiveRecord::Base  
has\_attachment :content\_type =\> :image,  
… etc…  
validates\_as\_attachment  
belongs\_to :post  
end

The problem is I don’t actually want to create new records in the  
attachments table until the user submit the post, but I can’t use all  
the attachment\_fu goodness to show the images in a preview unless I  
create the attachments first. Suggestions?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![rubynuby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ba9def/32.png) [@rubynuby](https://www.ruby-forum.com/u/rubynuby)\
**Post date:** [January 26, 2008, 10:40am UTC](https://www.ruby-forum.com/t/previewing-a-post-with-an-attachment-fu-image/127210/2 "2008-01-26T10:40:41Z")

</div>

On 26/01/2008, rubynuby [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> has_attachment :content_type => :image,
> 
> ```
> 
> Thanks in advance.  
> I used multiple upload photos for my previous projects (using  
> attachment\_fu as well). I just made after user successfully uploaded  
> photos either from new action method or edit action method, redirect  
> them to edit action method that has photos “preview” of what they’ve  
> uploaded it where there is a remove button to remove each photos and  
> file\_field to upload more photos again.

–  
r9 = { name: Rie!, ym: riyari3, skype: rubyninja,  
li: [http://linkedin.com/in/ariekeren](http://linkedin.com/in/ariekeren),  
fb: [Buy Real Facebook Likes | Pay for FB Likes - Profile.to](http://profile.to/ariekeren),  
blog: [http://tinyurl.com/2bjgvn](http://tinyurl.com/2bjgvn) }

---

<div class="post-metadata">

**Author:** ![rubynuby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ba9def/32.png) [@rubynuby](https://www.ruby-forum.com/u/rubynuby)\
**Post date:** [January 26, 2008, 5:50pm UTC](https://www.ruby-forum.com/t/previewing-a-post-with-an-attachment-fu-image/127210/3 "2008-01-26T17:50:03Z")

</div>

thanks, but it sounds like you just have a Photo model, as opposed to  
one that belongs\_to another model? my situation is a little trickier  
because I don’t want to create the photos until the user is sure he  
wants to create the post the photos belongs\_to
