# Attachment\_fu and vCards (2 questions)

**URL:** <https://www.ruby-forum.com/t/attachment-fu-and-vcards-2-questions/106806>\
**Category:** Rails\
**Created:** [June 14, 2007, 10:14am UTC](https://www.ruby-forum.com/t/attachment-fu-and-vcards-2-questions/106806 "2007-06-14T10:14:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![monjurul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b9e5f3/32.png) [@monjurul](https://www.ruby-forum.com/u/monjurul)\
**Post date:** [June 14, 2007, 10:14am UTC](https://www.ruby-forum.com/t/attachment-fu-and-vcards-2-questions/106806/1 "2007-06-14T10:14:45Z")

</div>

I’ve been having some trouble figuring these two (probably simple)  
feats.

First, is there a way to make attachment\_fu override files a user  
uploads? I figure one way would be to make all the filenames and paths  
be the same, like /path/user\_id.extension, but my problem is that the I  
am accepting 3 different formats for the files (doc, pdf and txt) and  
I’m not sure how to set the proper extensions.

I tried searching far and low but couldn’t find much. Ideally it would  
be perfect if the filenames could be kept the same and I could some how  
check to find a user’s file in my create function and destroy it if it  
exists (destroy doesn’t seem to work within create).

My second question involves using the vpim gem to export user data in  
the vcard format. I followed an example I found on this forum  
([Exporting vcards from rails - Rails - Ruby-Forum](http://www.ruby-forum.com/topic/76716#120542)) almost exactly but  
receive the following error: “uninitialized constant Mime::VCF” pointing  
to this bit of code:

```
 format.vcf do
    send_data @user.to_vcard, :filename => "#{@user.id}.vcf",
      :type => 'text/directory'
  end

```

Any help is much appreciated, I am very new to rails but am learning a  
lot thanks to this forum.

---

<div class="post-metadata">

**Author:** ![monjurul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b9e5f3/32.png) [@monjurul](https://www.ruby-forum.com/u/monjurul)\
**Post date:** [December 11, 2008, 11:25am UTC](https://www.ruby-forum.com/t/attachment-fu-and-vcards-2-questions/106806/2 "2008-12-11T11:25:23Z")

</div>

Having the same problem with vpim while requesting the vcard via:  
[http://localhost:3000/contacts/1.vcf](http://localhost:3000/contacts/1.vcf)

The controller code:

def show  
@contact = Contact.find(params[:id])

```
respond_to do |format|
  format.html # show.html.erb
  format.xml { render :xml => @contact }
  format.vcf do
    send_data @contact.to_vcard_test, :filename => "#

```

{@contact.id}.vcf", :type =\> ‘text/x-vcard’  
end  
end  
end

And the respond of the webserver:  
“uninitialized constant Mime::VCF”

Any suggestions?

Greg

On 14 Jun. 2007, 09:14, Monjurul D. \<rails-mailing-l…@andreas-
