# File\_column howto (beginner)

**URL:** <https://www.ruby-forum.com/t/file-column-howto-beginner/56123>\
**Category:** Rails\
**Created:** [January 3, 2006, 2:46pm UTC](https://www.ruby-forum.com/t/file-column-howto-beginner/56123 "2006-01-03T14:46:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@bob](https://www.ruby-forum.com/u/bob)\
**Post date:** [January 3, 2006, 2:46pm UTC](https://www.ruby-forum.com/t/file-column-howto-beginner/56123/1 "2006-01-03T14:46:22Z")

</div>

I’m trying to use file\_column as a Rails plugin.  
Of course I read the doc (from Sebastian, this maillist) and little  
bit of source (as good as I, newbie, could understand it)…

But I’m not able to implement it in my app… I’m a totally newbie with  
less software development experience.  
I get the file\_column\_field in my view with simply invoking the  
helper… (:multipart =\> true).

But what’s next?

- Do I need to declare the instance methods in my model class?
- What do I need to do with my controller, to get the process work?

Maybe somebody could provide me a little example source of model,  
controller, view?  
Thank you.

---

<div class="post-metadata">

**Author:** ![bob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@bob](https://www.ruby-forum.com/u/bob)\
**Post date:** [January 3, 2006, 3:56pm UTC](https://www.ruby-forum.com/t/file-column-howto-beginner/56123/2 "2006-01-03T15:56:39Z")

</div>

Can I use file\_column with PostgreSql?

Citeren Jonathan W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![bob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@bob](https://www.ruby-forum.com/u/bob)\
**Post date:** [January 3, 2006, 3:30pm UTC](https://www.ruby-forum.com/t/file-column-howto-beginner/56123/3 "2006-01-03T15:30:26Z")

</div>

Bob wrote:

> - Do I need to declare the instance methods in my model class?
> - What do I need to do with my controller, to get the process work?

#Model:

class A \< ActiveRecord::Base  
file\_column :file  
end

#Controller:  
@a = A.find(:first)

#View to upload file  
\<%= file\_column\_field ‘a’,‘file’ %\>

#View to display file  
\<%= url\_for\_file\_column ‘a’,‘file’ %\>

`file` is the name of the model attribute that will save the filename.  
So in your SQL you need:

`file` varchar(255) default NULL

Of course you can choose another name.

Jonathan

---

<div class="post-metadata">

**Author:** ![bob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@bob](https://www.ruby-forum.com/u/bob)\
**Post date:** [January 3, 2006, 4:52pm UTC](https://www.ruby-forum.com/t/file-column-howto-beginner/56123/4 "2006-01-03T16:52:12Z")

</div>

Bob wrote:

> Can I use file\_column with PostgreSql?

AFAIK yes as the file is stored on the filesystem and only the filename  
will be stored in the database. So you could use any of the supported  
databases.

The actual file will be stored in

public/MODELNAME/ID/FILENAME

Jonathan
