# FileColumn help

**URL:** <https://www.ruby-forum.com/t/filecolumn-help/95229>\
**Category:** Rails\
**Created:** [January 15, 2006, 5:01am UTC](https://www.ruby-forum.com/t/filecolumn-help/95229 "2006-01-15T05:01:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Castro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/dec6dc/32.png) [@Alex\_Castro](https://www.ruby-forum.com/u/Alex_Castro)\
**Post date:** [January 15, 2006, 5:01am UTC](https://www.ruby-forum.com/t/filecolumn-help/95229/1 "2006-01-15T05:01:52Z")

</div>

I’m trying to upload an image that will be displayed alongside a user  
profile.  
I’ve been trying to use FileColumn but haven’t had any luck. I don’t  
receive any  
errors, I just don’t get the file on the server.

Does anyone have any sample code they could share that demonstrates how  
I should  
use FileColumn?

Thx  
Alex

---

<div class="post-metadata">

**Author:** ![Alex\_Castro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/dec6dc/32.png) [@Alex\_Castro](https://www.ruby-forum.com/u/Alex_Castro)\
**Post date:** [January 15, 2006, 5:12am UTC](https://www.ruby-forum.com/t/filecolumn-help/95229/2 "2006-01-15T05:12:11Z")

</div>

Be certain your upload forms are multipart. Here is some working code.

## in the model

class InsuranceForm \< ActiveRecord::Base  
file\_column :form\_document  
validates\_presence\_of :form\_title  
validates\_presence\_of :description  
validates\_presence\_of :form\_document  
end

## in the view

\<%= error\_messages\_for ‘insurance\_form’ %\>

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

Form title  
\<%= text\_field 'insurance\_form', 'form\_title' %\>

Description  
\<%= text\_area 'insurance\_form', 'description' %\>

Form document  
\<%= file\_column\_field 'insurance\_form', 'form\_document' %\>

\<%= end\_form\_tag %\>

\<%= link\_to ‘Back’, :action =\> ‘list’ %\>

## in the controller

def new  
@insurance\_form = InsuranceForm.new  
end

def create  
@insurance\_form = InsuranceForm.new(params[:insurance\_form])  
if @insurance\_form.save  
flash[:notice] = ‘InsuranceForm was successfully created.’  
redirect\_to :action =\> ‘list’  
else  
render :action =\> ‘new’  
end  
end

---

<div class="post-metadata">

**Author:** ![Alex\_Castro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/dec6dc/32.png) [@Alex\_Castro](https://www.ruby-forum.com/u/Alex_Castro)\
**Post date:** [March 15, 2007, 10:29pm UTC](https://www.ruby-forum.com/t/filecolumn-help/95229/3 "2007-03-15T22:29:13Z")

</div>

Just wanted to say thanks for the info. Even though this was posted  
awhile ago, it helped me get my uploading to work!!!
