# Attachment\_fu related to another table

**URL:** <https://www.ruby-forum.com/t/attachment-fu-related-to-another-table/114946>\
**Category:** Rails\
**Created:** [September 19, 2007, 2:48am UTC](https://www.ruby-forum.com/t/attachment-fu-related-to-another-table/114946 "2007-09-19T02:48:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f9ae1b/32.png) [@nick](https://www.ruby-forum.com/u/nick)\
**Post date:** [September 19, 2007, 2:48am UTC](https://www.ruby-forum.com/t/attachment-fu-related-to-another-table/114946/1 "2007-09-19T02:48:20Z")

</div>

Dear all,

I created a site that asks for personal information such as Name, Age,  
Etc… and saves it into a MySQL database table. Now I would like to  
link a personal picture to these profiles. I have successfully  
implemented a picture upload with attachment\_fu. However, all the  
picture metadata is saved in the attachment\_fu table. What is the best  
procedure to link the profile table with the attachment\_fu table in  
order to retrieve the filename of the picture ? Also, when users want  
to change their picture, how do I make sure that the previous picture  
gets deleted. Right now attachment\_fu keeps adding new pictures.

I could not find examples on the web for this. This must be a common  
problem.

Thank you,

Nick,

---

<div class="post-metadata">

**Author:** ![nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f9ae1b/32.png) [@nick](https://www.ruby-forum.com/u/nick)\
**Post date:** [September 19, 2007, 4:02pm UTC](https://www.ruby-forum.com/t/attachment-fu-related-to-another-table/114946/2 "2007-09-19T16:02:22Z")

</div>

On 19 Sep 2007, at 02:47, Nick wrote:

> I could not find examples on the web for this. This must be a common  
> problem.

Use a one-on-one relationship (has\_one) with the image table. To  
replace the existing one: destroy the old one and then create a new one.

Best regards

Peter De Berdt
