# File\_column problem

**URL:** <https://www.ruby-forum.com/t/file-column-problem/83807>\
**Category:** Rails\
**Created:** [December 31, 2005, 1:15am UTC](https://www.ruby-forum.com/t/file-column-problem/83807 "2005-12-31T01:15:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [December 31, 2005, 1:15am UTC](https://www.ruby-forum.com/t/file-column-problem/83807/1 "2005-12-31T01:15:12Z")

</div>

I have been trying to use file\_column, and it does work partially, the  
files are uploaded to my server, but then when I do @user.icon it  
returns nil. My file\_column definition looks like this: file\_column  
:icon, :magick =\> {:size =\> “100x100” }

I display it in a form (with multipart) like this:  
\<%= file\_column\_field ‘user’, ‘icon’ %\>

I have noticed in the params that the icon is a StringIO (which is  
normal for files under 10kb), but icon\_temp is nil. I am using  
file\_column .3.1.

Thanks,  
Ben H.

---

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [December 31, 2005, 6:02pm UTC](https://www.ruby-forum.com/t/file-column-problem/83807/2 "2005-12-31T18:02:00Z")

</div>

Hi Ben,

On 12/31/05, Ben H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I have been trying to use file\_column, and it does work partially, the  
> files are uploaded to my server, but then when I do @user.icon it  
> returns nil. My file\_column definition looks like this: file\_column  
> :icon, :magick =\> {:size =\> “100x100” }

have you added a varchar column to your users table? This column will  
hold the filename.

Sebastian

---

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [December 31, 2005, 11:12pm UTC](https://www.ruby-forum.com/t/file-column-problem/83807/3 "2005-12-31T23:12:02Z")

</div>

> have you added a varchar column to your users table? This column will  
> hold the filename.
> 
> Sebastian

Thanks, it now stores the URL, but when I try and access the image, it  
gives me a routing error.

---

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [January 1, 2006, 4:57am UTC](https://www.ruby-forum.com/t/file-column-problem/83807/4 "2006-01-01T04:57:49Z")

</div>

Ben H. wrote:

> > have you added a varchar column to your users table? This column will  
> > hold the filename.
> > 
> > Sebastian
> 
> Thanks, it now stores the URL, but when I try and access the image, it  
> gives me a routing error.

Make sure to use a file with an extension like `.pdf`. A file without an  
extension like `README` will result in an routing error due to the stuff  
in .htaccess or the default lighttpd config.

Jonathan

---

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [January 1, 2006, 4:25pm UTC](https://www.ruby-forum.com/t/file-column-problem/83807/5 "2006-01-01T16:25:38Z")

</div>

> Make sure to use a file with an extension like `.pdf`. A file without an  
> extension like `README` will result in an routing error due to the stuff  
> in .htaccess or the default lighttpd config.
> 
> Jonathan

I am using .jpg’s, although could my .htaccess or lighttpd config be  
messed incorrect, since I am on Dreamhost?

---

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [January 2, 2006, 10:42am UTC](https://www.ruby-forum.com/t/file-column-problem/83807/6 "2006-01-02T10:42:10Z")

</div>

Ben H. wrote:

> > Make sure to use a file with an extension like `.pdf`. A file without an  
> > extension like `README` will result in an routing error due to the stuff  
> > in .htaccess or the default lighttpd config.
> > 
> > Jonathan
> 
> I am using .jpg’s, although could my .htaccess or lighttpd config be  
> messed incorrect, since I am on Dreamhost?

If you use Apache it is most likely that they allow you `.htaccess`  
files and then it is under your control. But unless you changed it this  
problem affects only files with no extension.

How to you access the image?

In the accessing view you need:

\<%= url\_for\_file\_column ‘user’, ‘icon’ %\>

Jonathan

---

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [January 3, 2006, 12:36am UTC](https://www.ruby-forum.com/t/file-column-problem/83807/7 "2006-01-03T00:36:54Z")

</div>

> How to you access the image?
> 
> Jonathan

I use this: \<%= image\_tag url\_for\_file\_column(‘user’, ‘icon’), { :class  
=\> ‘profilepic’ } %\>  
Which is equivalent to what you said, right?

---

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [January 4, 2006, 1:33am UTC](https://www.ruby-forum.com/t/file-column-problem/83807/8 "2006-01-04T01:33:12Z")

</div>

Ben H. wrote:

> > How to you access the image?
> > 
> > Jonathan

I figured out the problem. For some reason the images were created with  
incorrect permissions, which caused them to not be accessible.
