# Problems with file\_column plugin

**URL:** <https://www.ruby-forum.com/t/problems-with-file-column-plugin/102248>\
**Category:** Rails\
**Created:** [August 14, 2006, 12:46am UTC](https://www.ruby-forum.com/t/problems-with-file-column-plugin/102248 "2006-08-14T00:46:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivanstorck](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e99b99/32.png) [@ivanstorck](https://www.ruby-forum.com/u/ivanstorck)\
**Post date:** [August 14, 2006, 12:46am UTC](https://www.ruby-forum.com/t/problems-with-file-column-plugin/102248/1 "2006-08-14T00:46:00Z")

</div>

1. installation is not as smooth as some other plug-ins. If you follow  
the instructions on  
[http://www.kanthak.net/opensource/file\_column/](http://www.kanthak.net/opensource/file_column/)

it makes a directory called trunk instead of file\_column. You have to  
manually rename it to file\_column. I guess this is a minor annoyance but  
it gives me the feeling that things aren’t quite like other plugins.

1. I get this error: undefined method `file\_column’ for Mymodel:Class  
after following the directions to to that on the same page. I thought it  
was maybe because I had to add require ‘rails\_file\_column’ to  
environment.rb but I still get the same error

Does anyone have an example of a getting this plugin working? A complete  
example would be great (model, list and form views, and controller, and  
schema)  
[http://wiki.rubyonrails.org/rails/pages/HowToUseFileColumn](http://wiki.rubyonrails.org/rails/pages/HowToUseFileColumn) only has  
model and view code

thanks!

---

<div class="post-metadata">

**Author:** ![ivanstorck](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e99b99/32.png) [@ivanstorck](https://www.ruby-forum.com/u/ivanstorck)\
**Post date:** [August 14, 2006, 8:48am UTC](https://www.ruby-forum.com/t/problems-with-file-column-plugin/102248/2 "2006-08-14T08:48:48Z")

</div>

in the db you need a text type column for the path that is stored in the  
coresponding model; so the whole story would go like this:

Db:

(1)  
some\_table  
id int …  
foo (file\_column\_field–you can call this whatever you want–)  
varchar(255) not null…  
…  
primary key (id) …

(2)you must download the file\_column instructions from sabastian’s page  
(it’s actually quite simple; just copy the ruby script/plugin install  
http:// … into the directory of your application (it is done for every  
application, not entirely for rails, as far as i know)

(3)in the model of SomeTable, put:

Class SomeTable  
file\_column :foo  
end

(4) to put it in a form do:

start\_form\_tag ({:action =\> … }, :mulitpart =\> true ) # so that it can  
recieve  
files, encoding issues…  
…  
…  
…  
file\_column\_field ‘some\_table’, ‘foo’  
end\_form\_tag

and then, to get the relative path to the file that was downloaded do:

@var = SomeTable.find(theoneyouwant)

url\_for\_file\_column(“var”, “foo”)  
to get what you want.

[[[  
can be image\_tag(url\_for\_file\_column(“var”, “foo”)) or  
link\_to(url\_for\_file\_column(“var”, “foo”)) etc.  
]]]

hope it helps.

harp

---

<div class="post-metadata">

**Author:** ![ivanstorck](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e99b99/32.png) [@ivanstorck](https://www.ruby-forum.com/u/ivanstorck)\
**Post date:** [August 18, 2006, 8:54am UTC](https://www.ruby-forum.com/t/problems-with-file-column-plugin/102248/3 "2006-08-18T08:54:37Z")

</div>

Thanks, Harp! It works, mostly. It works great in my new, edit, and show  
methods, but not in the list method. The error I get is:

Showing app/views/cabmembers/list.rhtml where line #6 raised:

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

Extracted source (around line #6):

3: \<% for cabmember in @cabmembers %\>  
4:

  
5: 
  
6: \<%= image\_tag url\_for\_file\_column( ‘cabmember’, ‘logo’ ) %\>  
7: 

I think the nil object has something to do with me not knowing how to  
pass url\_for\_file\_column the right info?? Any ideas?

---

<div class="post-metadata">

**Author:** ![ivanstorck](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e99b99/32.png) [@ivanstorck](https://www.ruby-forum.com/u/ivanstorck)\
**Post date:** [August 18, 2006, 4:38pm UTC](https://www.ruby-forum.com/t/problems-with-file-column-plugin/102248/4 "2006-08-18T16:38:39Z")

</div>

I believe url\_for\_file\_column requires an instance variable (i.e. one  
with an @ before it). So you could try this:

\<% for @cabmember in @cabmembers %\>

\<%= image\_tag url\_for\_file\_column( 'cabmember', 'logo' ) %\>

-Greg

---

<div class="post-metadata">

**Author:** ![ivanstorck](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e99b99/32.png) [@ivanstorck](https://www.ruby-forum.com/u/ivanstorck)\
**Post date:** [September 15, 2006, 9:38am UTC](https://www.ruby-forum.com/t/problems-with-file-column-plugin/102248/5 "2006-09-15T09:38:35Z")

</div>

This is a late reply, but I’m also having problems with file\_column

The svn install didn’t work so I copied the files manually into  
vendor/plugins and renamed the dir file\_column

I think my problem is in the require statements in environment.rb

At the moment I have

require ‘file\_column’  
require ‘file\_column\_helper’  
require ‘rails\_file\_column’

at the bottom of the environment.rb file. Im not sure about the syntax  
here, in particular whether I need to specify the filepath, or move  
these from the vendor folder to a higher lib. Im also not sure if they  
are in the correct place in the environment.rb file.

The error I am getting is when trying to save the file;

Do not know how to handle a string with value ‘060910 rebecca cannon  
radio.jpg’ that was passed to a file\_column. Check if the form’s  
encoding has been set to ‘multipart/form-data’.

(Even tho my form specifies multipart:

\<%= start\_form\_tag :action =\> ‘create’, :multipart =\> true %\>

Any suggestions appreciated.

---

<div class="post-metadata">

**Author:** ![ivanstorck](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e99b99/32.png) [@ivanstorck](https://www.ruby-forum.com/u/ivanstorck)\
**Post date:** [September 15, 2006, 9:59am UTC](https://www.ruby-forum.com/t/problems-with-file-column-plugin/102248/6 "2006-09-15T09:59:00Z")

</div>

user error syntax problem as usual

\<%= start\_form\_tag :action =\> ‘create’, :multipart =\> true %\>

should have been

\<%= start\_form\_tag({:action =\> ‘create’}, {:multipart =\> true}) %\>
