# Questions about file\_column plugin

**URL:** <https://www.ruby-forum.com/t/questions-about-file-column-plugin/55079>\
**Category:** Rails\
**Created:** [March 16, 2006, 9:36pm UTC](https://www.ruby-forum.com/t/questions-about-file-column-plugin/55079 "2006-03-16T21:36:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [March 16, 2006, 9:36pm UTC](https://www.ruby-forum.com/t/questions-about-file-column-plugin/55079/1 "2006-03-16T21:36:18Z")

</div>

Hi!

I’ve got 2 models - let’s call them User and Image. User has\_many  
images. (Thanks to Mark Reginal James 🙂 ) I have a single form where i  
can create a user and add to him any number of images, which are  
uploaded using file\_column plugin.

Now 3 questions:

1. How to change the default path where file\_column plugin saves images,  
so it will save them in a directory, which name is not image id, but  
user id to which the image belongs to?

2. When user objects fails validation, but images were ok, i’d like to  
display thumbnails of temporarly uploaded files by file\_column, so that  
user can see that they were acutally correctly uploaded. What is the  
name of the variable in file\_column that keeps path to the images and  
how to access it from the view?

3. What is the best way to automatically delete files in the “tmp”  
folder? It gets huge very quickly. I don’t think that scheduling  
deleting of these files is good solution, because user could be filling  
his form while tmp folder is being deleted. Maybe i could somehow add a  
callback that it will delete temporary image if it was succesfully  
saved? But how? 🙂

That’s all. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [March 17, 2006, 11:02am UTC](https://www.ruby-forum.com/t/questions-about-file-column-plugin/55079/2 "2006-03-17T11:02:19Z")

</div>

It turned out that i wasn’t using latest trunk version of file\_column  
plugin. New version solved above mentioned problems, but introduced a  
new one.

If i specify dynamic default storage dir for images like this:

file\_column :name,  
:store\_dir =\> :dynamic\_dir

def dynamic\_dir  
File.join(“images”,“properties”,self.property.id.to\_s)  
end

how can i later access images using url\_for\_file\_column method? It seems  
to be ignoring :store\_dir option.

---

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [March 17, 2006, 4:17pm UTC](https://www.ruby-forum.com/t/questions-about-file-column-plugin/55079/3 "2006-03-17T16:17:30Z")

</div>

you could schedule deletion of files that were 24hrs+ old in unix with  
something like this:

find /full/img/path/tmp/ -type d -mtime -1 -exec rm -r {};

so, find in the path things of type ‘directory’ 1 day old (at least)  
then rm -r each directory.  
(you should probably test that 🙂 )

not sure about the other bits…
