# File\_column

**URL:** <https://www.ruby-forum.com/t/file-column/91786>\
**Category:** Rails\
**Created:** [December 1, 2005, 10:35pm UTC](https://www.ruby-forum.com/t/file-column/91786 "2005-12-01T22:35:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![scidept](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ba0ec/32.png) [@scidept](https://www.ruby-forum.com/u/scidept)\
**Post date:** [December 1, 2005, 10:35pm UTC](https://www.ruby-forum.com/t/file-column/91786/1 "2005-12-01T22:35:23Z")

</div>

I’m trying to use the file\_column plugin, and the upload portion of it  
works  
beautifully.  
I’m trying to display the images now and I’m having a couple problems.  
First is, when I try to use url\_for\_file\_column, I get the following  
error:  
You have a nil object when you didn’t expect it!  
The error occured while evaluating nil.image\_relative\_path

The Code I’m using is this:  
\<% for photo in @photos %\>

```
<td><%= image_tag url_for_file_column("photo", "image") %></td>

<td><%=h item.name %></td>

<td><%=h item.description %></td>

<td><%= link_to 'Show', :action => 'show', :id => item %></td>

<td><%= link_to 'Edit', :action => 'edit', :id => item %></td>

<td><%= link_to 'Destroy', { :action => 'destroy', :id => item },

```

:confirm =\> ‘Are you sure?’ %\>

\<% end %\>

Second, I don’t know how to specify which version of the photo I  
uploaded to  
use.  
I have a “thumb” and a “medium” and then the native size uploaded. How  
do I  
differentiate between the two?

Any help is appreciated,  
Thanks,  
BJ Clark

---

<div class="post-metadata">

**Author:** ![scidept](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ba0ec/32.png) [@scidept](https://www.ruby-forum.com/u/scidept)\
**Post date:** [December 1, 2005, 10:43pm UTC](https://www.ruby-forum.com/t/file-column/91786/2 "2005-12-01T22:43:29Z")

</div>

Hi !

2005/12/1, BJ Clark [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> I’m trying to display the images now and I’m having a couple problems.  
> First is, when I try to use url\_for\_file\_column, I get the following error:  
> You have a nil object when you didn’t expect it!  
> The error occured while evaluating nil.image\_relative\_path

This is because you need to have an instance variable and not a local  
one:  
\<% for @photo in @photos %\>  
…  
\<% end %\>

> Second, I don’t know how to specify which version of the photo I uploaded to  
> use.  
> I have a “thumb” and a “medium” and then the native size uploaded. How do I  
> differentiate between the two?

url\_for\_file\_column has a third parameter - version. If you leave it  
off, you’ll get the original size, else you’ll get that named version.

Hope that helps !

---

<div class="post-metadata">

**Author:** ![scidept](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ba0ec/32.png) [@scidept](https://www.ruby-forum.com/u/scidept)\
**Post date:** [December 1, 2005, 11:28pm UTC](https://www.ruby-forum.com/t/file-column/91786/3 "2005-12-01T23:28:06Z")

</div>

Works beautifully!  
Thanks,  
BJ Clark

---

<div class="post-metadata">

**Author:** ![scidept](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ba0ec/32.png) [@scidept](https://www.ruby-forum.com/u/scidept)\
**Post date:** [September 25, 2007, 11:05pm UTC](https://www.ruby-forum.com/t/file-column/91786/4 "2007-09-25T23:05:29Z")

</div>

On 6/29/07, Yann KLIS [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Juste pour info, attachment\_fu est le successeur de acts\_as\_attachment.  
> Quant Ã file\_column, le plugin est un peu mort (pas de mise Ã jour depuis  
> 2005), la commande d’install sur la page web ne fonctionne pas (la derniÃ¨re  
> fois que j’avais essayÃ© en tout cas, ce qui remonte Ã quelques mois  
> maintenant), etc.

Je suis d’accord avec Yann, de plus attachment\_fu est beaucoup plus  
modulaire, et propose des hooks partout ou on en a besoin (before  
thumbnail,  
before\_resize …), supporte les fichiers en DB, ou sur S3 et pas  
seulement  
les fichiers plats, offre la possibilitÃ© de resizer les images avec  
imageMagick ou image Science, … C’est un des rares plugin que je n’ai  
pas  
eu une folle envie de patcher pour le faire rentrer dans mes besoins.  
Les  
tests sont trÃ¨s bien fait et Rick a rajoutÃ© d’excellent helper pour  
faciliter le tout.

Son seul dÃ©faut Ã mon avis, il est totalement concu pour stocker les  
fichiers Ã uploader, c’est Ã dire que les fonctions acceptent comme  
argument  
des UploadedFile facon CGI. RÃ©sultat pour utiliser le plugin afin de  
stocker  
ou par exemple peupler sa base de donnÃ©e il faut faire du duck typing  
pour  
fournir un Object qui ressemble Ã ce qu’il attend. Ce qui est un peu  
chiant  
quand on stocke sur S3 ou en DB mais ne pose pas de problÃ¨me quand ce  
sont  
des fichiers plats car rails a tout ce qu’il faut.

Renaud

---

<div class="post-metadata">

**Author:** ![scidept](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ba0ec/32.png) [@scidept](https://www.ruby-forum.com/u/scidept)\
**Post date:** [December 2, 2005, 11:02am UTC](https://www.ruby-forum.com/t/file-column/91786/5 "2005-12-02T11:02:05Z")

</div>

“You have a nil object when you didn’t expect it!  
The error occured while evaluating nil.image\_relative\_path”

You also get this or a similar error if the image field has not had a  
path/filename set.  
So you can either set a default value in the database, say  
“/images/default.jpg” or do  
image\_tag url\_for\_file\_column(“photo”, “image”) if @photo.image

Kris.
