Rails Accessing an Uploaded File and Saving it to PaperClip

Hello, I'm using the following file uploader with Rails 3:

The uploader on the client side is working fine. I can see in the Rails log file that the following is being posted when I upload a file:

    Started POST "/attachments/upload" for 127.0.0.1 at Mon Jan 24 14:15:25 -0800 2011       Processing by AttachmentsController#upload as */*       Parameters: {"_http_accept"=>"application/javascript", "authenticity_token"=>"F1h9pvCZL9HUgTjwCIAMc%252BW1cYwx7eBOPwThHfbS5ZU %253D", "file"=>#<ActionDispatch::Http::UploadedFile:0x1076a6d48 @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"file\"; filename=\"joecocker.jpg\"\r\nContent-Type: image/jpeg\r \n", @original_filename="joecocker.jpg", @tempfile=#<File:/var/folders/ lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/RackMultipart20110124-12264- rbtnth-0>>}

The issue I'm having is I'm unable to save the uploaded file to Paperclip.

I've ried:

    @attachment = Attachment.create(:attachment => File.open(params[:file].tempfile.path))     @attachment = Attachment.create(:attachment => params[:file].tempfile.path)

And neither work. Paperclip inserts a file attachment name of "RackMultipart20110124-12264-rbtnth-0"

Any ideas / suggestions on how to save the file to paperclip? thanks

Hello, I’m using the following file uploader with Rails 3:

https://github.com/blueimp/jQuery-File-Upload

The uploader on the client side is working fine. I can see in the

Rails log file that the following is being posted when I upload a

file:

Started POST "/attachments/upload" for 127.0.0.1 at Mon Jan 24

14:15:25 -0800 2011

  Processing by AttachmentsController#upload as */*

  Parameters: {"_http_accept"=>"application/javascript",

“authenticity_token”=>"F1h9pvCZL9HUgTjwCIAMc%252BW1cYwx7eBOPwThHfbS5ZU

%253D", “file”=>#<ActionDispatch::Http::UploadedFile:0x1076a6d48

@content_type=“image/jpeg”, @headers="Content-Disposition: form-data;

name="file"; filename="joecocker.jpg"\r\nContent-Type: image/jpeg\r

\n", @original_filename=“joecocker.jpg”, @tempfile=#<File:/var/folders/

lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/RackMultipart20110124-12264-

rbtnth-0>>}

The issue I’m having is I’m unable to save the uploaded file to

Paperclip.

I’ve ried:

@attachment = Attachment.create(:attachment =>

File.open(params[:file].tempfile.path))

@attachment = Attachment.create(:attachment =>

params[:file].tempfile.path)

It should happen almost automatically. Make sure:

Model:

has_attached_file :attachment

View – make sure multipart:

<%= form_for(@attachment, :html => { :multipart => true }) do |f| %>

Controller – should be business as usual –

@attachment = Attachment.new(params[:billing_run])