# Filecolumn storage location

**URL:** <https://www.ruby-forum.com/t/filecolumn-storage-location/55740>\
**Category:** Rails\
**Created:** [March 23, 2006, 2:39pm UTC](https://www.ruby-forum.com/t/filecolumn-storage-location/55740 "2006-03-23T14:39:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jordelver](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@jordelver](https://www.ruby-forum.com/u/jordelver)\
**Post date:** [March 23, 2006, 2:39pm UTC](https://www.ruby-forum.com/t/filecolumn-storage-location/55740/1 "2006-03-23T14:39:41Z")

</div>

Hi,  
I am using file\_column for some image uploading. I want to have all  
the images stored under one root which I have managed by setting the  
:store\_dir option as below.

file\_column :filename, :store\_dir =\> File.join(RAILS\_ROOT, ‘public’,  
‘images’, ‘products’)

So, my images get uploaded to:

/public/images/products/\<primary\_key\>

That’s fine. But none of my links to the images work.

What am I doing wrong?

Thanks,  
Jordan

---

<div class="post-metadata">

**Author:** ![jordelver](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@jordelver](https://www.ruby-forum.com/u/jordelver)\
**Post date:** [March 23, 2006, 3:45pm UTC](https://www.ruby-forum.com/t/filecolumn-storage-location/55740/2 "2006-03-23T15:45:50Z")

</div>

Hi,  
did you checked permissions?

–  
View this message in context:  
[http://www.nabble.com/Filecolumn-storage-location-t1330285.html#a3552630](http://www.nabble.com/Filecolumn-storage-location-t1330285.html#a3552630)  
Sent from the RubyOnRails Users forum at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![jordelver](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@jordelver](https://www.ruby-forum.com/u/jordelver)\
**Post date:** [March 23, 2006, 4:09pm UTC](https://www.ruby-forum.com/t/filecolumn-storage-location/55740/3 "2006-03-23T16:09:19Z")

</div>

> did you checked permissions?

The permissions look ok. Basically, I should of said before that the  
url being generated is incorrect. The url\_for\_image\_column generates  
this:

/images/products/image/filename/9/thumb/PIC1083486196.jpg

When it should be this:

/images/products/9/thumb/PIC1083486196.jpg

So, the model and the attribute are being put into the url regardless.  
I don’t know why though? Looking at the file\_column helper code (I am  
a newbie though), the model and attribute seem to get added to the url  
regardless of if you set the :web\_root or not.

Any more ideas?

Thanks for any help,  
Jordan

---

<div class="post-metadata">

**Author:** ![jordelver](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@jordelver](https://www.ruby-forum.com/u/jordelver)\
**Post date:** [March 24, 2006, 2:25pm UTC](https://www.ruby-forum.com/t/filecolumn-storage-location/55740/4 "2006-03-24T14:25:18Z")

</div>

There also :base\_dir option that may be useful for you, which if i  
remember correctly is “:web\_root + model\_name + column”. You can  
override it with “sub\_dir/” and it should work.

---

<div class="post-metadata">

**Author:** ![jordelver](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@jordelver](https://www.ruby-forum.com/u/jordelver)\
**Post date:** [March 24, 2006, 1:53pm UTC](https://www.ruby-forum.com/t/filecolumn-storage-location/55740/5 "2006-03-24T13:53:13Z")

</div>

On 3/23/06, Jordan E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> /images/products/9/thumb/PIC1083486196.jpg
> 
> So, the model and the attribute are being put into the url regardless.  
> I don’t know why though? Looking at the file\_column helper code (I am  
> a newbie though), the model and attribute seem to get added to the url  
> regardless of if you set the :web\_root or not.
> 
> Any more ideas?

I had the same problem. But I gave in and let the model and attribute  
be in the path, but still got everything under one subdirectory by  
passing:

:web\_root =\> “sub\_dir/”

and

:root\_path =\> File.join(RAILS\_ROOT, “public”, “sub\_dir”)

Seemed kind of like a hack though…

Justin

---

<div class="post-metadata">

**Author:** ![jordelver](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@jordelver](https://www.ruby-forum.com/u/jordelver)\
**Post date:** [March 24, 2006, 5:53pm UTC](https://www.ruby-forum.com/t/filecolumn-storage-location/55740/6 "2006-03-24T17:53:02Z")

</div>

Thanks for the replies.

> There also :base\_dir option that may be useful for you, which if i  
> remember correctly is “:web\_root + model\_name + column”. You can  
> override it with “sub\_dir/” and it should work.

I think you’re thinking of :base\_url. I’ve just changed the file\_column  
line to:

file\_column :filename, :store\_dir =\> File.join(RAILS\_ROOT, ‘public’,  
‘images’, ‘products’), :base\_url =\> File.join(‘images’, ‘products’)

So, the files are saved to the :store\_dir location and the url to the  
files is changed with :base\_url to /images/products/.

Thanks for the pointers 🙂

Cheers,  
Jord
