# File\_column content type

**URL:** <https://www.ruby-forum.com/t/file-column-content-type/51981>\
**Category:** Rails\
**Created:** [January 9, 2006, 10:21pm UTC](https://www.ruby-forum.com/t/file-column-content-type/51981 "2006-01-09T22:21:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![adamdorsey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ed8c4c/32.png) [@adamdorsey](https://www.ruby-forum.com/u/adamdorsey)\
**Post date:** [January 9, 2006, 10:21pm UTC](https://www.ruby-forum.com/t/file-column-content-type/51981/1 "2006-01-09T22:21:53Z")

</div>

is there a way using the file\_column plugin to enforce a certain  
content type based on regex (i.ie, /^image/) and/or filesize (150k)  
?

thanks  
adam

---

<div class="post-metadata">

**Author:** ![adamdorsey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ed8c4c/32.png) [@adamdorsey](https://www.ruby-forum.com/u/adamdorsey)\
**Post date:** [January 9, 2006, 10:24pm UTC](https://www.ruby-forum.com/t/file-column-content-type/51981/2 "2006-01-09T22:24:58Z")

</div>

On 1/9/06, Adam D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

[http://opensvn.csie.org/rails\_file\_column/plugins/file\_column/trunk/lib/validations.rb](http://opensvn.csie.org/rails_file_column/plugins/file_column/trunk/lib/validations.rb)

–  
Kyle M.  
Chief Technologist  
E Factor Media // FN Interactive  
removed\_email\_address@domain.invalid  
1-866-263-3261

---

<div class="post-metadata">

**Author:** ![adamdorsey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ed8c4c/32.png) [@adamdorsey](https://www.ruby-forum.com/u/adamdorsey)\
**Post date:** [January 10, 2006, 4:00am UTC](https://www.ruby-forum.com/t/file-column-content-type/51981/3 "2006-01-10T04:00:17Z")

</div>

thanks. now for an even dumber question. Isnt rails supposed to  
automatically load the vendor directory ? I installed file\_column  
but i get a

undefined method `file\_column’ for #\<#Class:0x40847dc0:0x40847aa0\>  
when using it in the model

cant seem to find where to “require” file\_column if thats necessary.

adam

---

<div class="post-metadata">

**Author:** ![adamdorsey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ed8c4c/32.png) [@adamdorsey](https://www.ruby-forum.com/u/adamdorsey)\
**Post date:** [January 10, 2006, 11:33am UTC](https://www.ruby-forum.com/t/file-column-content-type/51981/4 "2006-01-10T11:33:29Z")

</div>

On 1/10/06, Adam D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> thanks. now for an even dumber question. Isnt rails supposed to  
> automatically load the vendor directory ? I installed file\_column  
> but i get a
> 
> undefined method `file\_column’ for #\<#Class:0x40847dc0:0x40847aa0\>  
> when using it in the model
> 
> cant seem to find where to “require” file\_column if thats necessary.

file\_column is designed as a plugin. This means you should just drop  
it into vendor/plugins/file-column or install it via

./script/plugin install   
[http://opensvn.csie.org/rails\_file\_column/plugins/file\_column/trunk](http://opensvn.csie.org/rails_file_column/plugins/file_column/trunk)

Hope this helps  
Sebastian

---

<div class="post-metadata">

**Author:** ![adamdorsey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ed8c4c/32.png) [@adamdorsey](https://www.ruby-forum.com/u/adamdorsey)\
**Post date:** [February 14, 2006, 12:59am UTC](https://www.ruby-forum.com/t/file-column-content-type/51981/5 "2006-02-14T00:59:57Z")

</div>

> file\_column is designed as a plugin. This means you should just drop  
> it into vendor/plugins/file-column or install it via
> 
> ./script/plugin install   
> [http://opensvn.csie.org/rails\_file\_column/plugins/file\_column/trunk](http://opensvn.csie.org/rails_file_column/plugins/file_column/trunk)

I have this same problem. I’ve run the command and file\_column is now  
sitting in my plugins folder. I tried restarting the webserver, but I  
still get this error:

## undefined method `file\_column’ for HomeImagesController:Class

And my controller looks like this:  
class HomeImagesController \< ApplicationController  
#model :home\_images # does this matter?  
file\_column :filename  
end

Do I need to “require” the plugin anywhere? It looks like it doesn’t  
recognize that it exists.

---

<div class="post-metadata">

**Author:** ![adamdorsey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ed8c4c/32.png) [@adamdorsey](https://www.ruby-forum.com/u/adamdorsey)\
**Post date:** [February 14, 2006, 1:08am UTC](https://www.ruby-forum.com/t/file-column-content-type/51981/6 "2006-02-14T01:08:17Z")

</div>

Your file\_column :filename should be in your Model, not your controller.

class HomeImages \< ActiveRecord::Base  
file\_column :filename  
end

Step 2 is to change your new and edit views to include :multipart =\>  
true, like this:

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

After that, edit your \_form partial to have the helper called:

File  
\<%= file\_column\_field("home\_images", "filename") %\>

You also shouldn’t need to call out your model unless rails is  
choking on it.

Enjoy!  
-J

On Feb 13, 2006, at 6:59 PM, Brandon wrote:

> still get this error:  
> Do I need to “require” the plugin anywhere? It looks like it doesn’t  
> recognize that it exists.

–

John A.  
removed\_email\_address@domain.invalid

Meticulous | [www.meticulous.com](http://www.meticulous.com) (work)  
Rotoscope | [www.rotoscope.com](http://www.rotoscope.com) (sound: rock band)  
Boboroshi & Kynz | [www.boboroshiandkynz.com](http://www.boboroshiandkynz.com) (sound: electronic)  
Personal Weblog | [www.boboroshi.com](http://www.boboroshi.com) (play)

“Those who would give up essential Liberty, to purchase a little  
temporary Safety, deserve neither Liberty nor Safety.”  
- Benjamin Franklin (1706-1790)  
Reply of the Pennsylvania Assembly to the  
Governor  
November 11, 1755
