# Retrieve an already uploaded file using upload column

**URL:** <https://www.ruby-forum.com/t/retrieve-an-already-uploaded-file-using-upload-column/146133>\
**Category:** Rails\
**Created:** [August 18, 2008, 11:07am UTC](https://www.ruby-forum.com/t/retrieve-an-already-uploaded-file-using-upload-column/146133 "2008-08-18T11:07:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [August 18, 2008, 11:07am UTC](https://www.ruby-forum.com/t/retrieve-an-already-uploaded-file-using-upload-column/146133/1 "2008-08-18T11:07:53Z")

</div>

Hi  
I am using the plugin upload column for file uploading…And it was  
working properly with the code  
@sd\_activity\_attachment=ServiceDeskActivityAttachment.new(params[:sd\_activity\_attachment])  
@sd\_activity\_attachment.service\_desk\_activity\_id=@sd\_activity.id.to\_i  
@sd\_activity\_attachment.save  
And in model ServiceDeskActivityAttachment  
upload\_column :attachment, :store\_dir =\> proc{|inst, attachment|  
“uploads/servicedeskactivity/#{inst.id}”}

```
And later according to my requiremnt I changed above controller code

```

and model code as  
@sd\_activity\_attachment=ServiceDeskActivityAttachment.new(params[:sd\_activity\_attachment])  
@sd\_activity\_attachment.service\_desk\_activity\_id=@sd\_activity.id.to\_i  
@sd\_activity\_attachment.company\_name=session[:company] # setting company  
from session to this model to store the respective attachment in company  
specific folder

@sd\_activity\_attachment.save  
And in model  
attr\_accessor :company\_name  
upload\_column :attachment, :store\_dir =\> proc{|inst, attachment|  
“uploads/servicedeskactivity/#{inst.company\_name}/#{inst.id}”}

```
      Now what happens is when i attach a file it goes to

```

RAILSROOT/public/uploads/servicedeskactivity/comp1/hello.jpg  
But I can’t retrieve that file  
And the file points to  
[http://localhost:3000/uploads/servicedeskactivity//1/hello.jpg](http://localhost:3000/uploads/servicedeskactivity//1/hello.jpg)  
instead of

[http://localhost:3000/uploads/servicedeskactivity/comp1/1/hello.jpg](http://localhost:3000/uploads/servicedeskactivity/comp1/1/hello.jpg)  
I figure out where the error is.Please help.Any change  
needed in source code of uploadcolumn?

Thanks in advance  
Sijo

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [August 18, 2008, 8:25pm UTC](https://www.ruby-forum.com/t/retrieve-an-already-uploaded-file-using-upload-column/146133/2 "2008-08-18T20:25:35Z")

</div>

Hey I see that you are storing the image in “uploads/  
servicedeskactivity/#{inst.id}” and you are checking it in “uploads/  
servicedeskactivity/comp1/1/hello.jpg”. Is it a typing mistake or am I  
wrong?. Hope that helps you.

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [August 19, 2008, 6:19am UTC](https://www.ruby-forum.com/t/retrieve-an-already-uploaded-file-using-upload-column/146133/3 "2008-08-19T06:19:01Z")

</div>

Hi  
I am storing  
upload\_column :attachment, :store\_dir =\> proc{|inst, attachment|  
“uploads/servicedeskactivity/#{inst.company\_name}/#{inst.id}”}

Sijo
