# File\_column trouble, advice needed

**URL:** <https://www.ruby-forum.com/t/file-column-trouble-advice-needed/61844>\
**Category:** Rails\
**Created:** [May 28, 2006, 7:58pm UTC](https://www.ruby-forum.com/t/file-column-trouble-advice-needed/61844 "2006-05-28T19:58:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anabia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/35a633/32.png) [@anabia](https://www.ruby-forum.com/u/anabia)\
**Post date:** [May 28, 2006, 7:58pm UTC](https://www.ruby-forum.com/t/file-column-trouble-advice-needed/61844/1 "2006-05-28T19:58:42Z")

</div>

Finally i have RMagick and the file\_column plugin installed, but at the  
time of uploading images i have trouble, i get “uninitialized constant  
ArtImage” error and other errors, im following the instructions on  
[Peak Obsession](http://wiki.rubyonrails.com/rails/pages/HowToUseFileColumn) but doesnt  
seems to work, this its the code im using:

#----view  
\<%= form\_tag({:action=\>‘create\_art\_image’, :id=\> @art\_image}, :multipart  
=\> true)%\>  
\<%= file\_column\_field “art\_image”, “image” %\>  
  
\<%= submit\_tag ‘Upload’ -%\>  
\<%= end\_form\_tag %\>

#—controller action  
def create\_art\_image  
@art\_image = ArtImage.new(@params[:art\_image])  
end

#----model  
file\_column :image

i have my table(items) fields asi this:  
id int  
title varchar  
content text  
image varchar

what i want to do its upload all the images to one folder and then later  
can be assigned to the items(on the image field im guessing), i just  
cant figure out how to make this work so if someone have a working  
example or any advice it will be very helpful.

🙂

---

<div class="post-metadata">

**Author:** ![anabia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/35a633/32.png) [@anabia](https://www.ruby-forum.com/u/anabia)\
**Post date:** [May 28, 2006, 8:12pm UTC](https://www.ruby-forum.com/t/file-column-trouble-advice-needed/61844/2 "2006-05-28T20:12:32Z")

</div>

Hi Ana,

Looking at your code, it looks as though your controller is trying to  
find a model called ArtImage, but can’t find it. Is that what you’ve  
named your model? Your model should have the following as the class  
name: class ArtImage \< ActiveRecord::Base. If it is, maybe try  
restarting your web server, if you haven’t already.

Take care,  
Sean

---

<div class="post-metadata">

**Author:** ![anabia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/35a633/32.png) [@anabia](https://www.ruby-forum.com/u/anabia)\
**Post date:** [May 28, 2006, 8:49pm UTC](https://www.ruby-forum.com/t/file-column-trouble-advice-needed/61844/3 "2006-05-28T20:49:48Z")

</div>

Yeah Sean, that was the problem, i set up the model and all worked well  
at least for a while, suddenly the uploads doenst work anymore, when i  
upload an image the

artimage  
-img  
-tmp

directory its created inside the public directory but no image inside  
and also a new row on the table its added but null, here its my  
working(for a minute) code:

#----view  
\<%= form\_tag({:action=\>‘create\_art\_image’, :id=\> @art\_image}, :multipart  
=\> true)%\>  
\<%= file\_column\_field “artimage”, “image” %\>  
  
\<%= submit\_tag ‘Upload’ -%\>  
\<%= end\_form\_tag %\>

#----controller action  
def create\_art\_image  
@art\_image = ArtImage.new(@params[:art\_image])  
if @art\_image.save  
flash[:notice] = ‘Upload sucessful’  
redirect\_to :action =\> ‘index’  
else  
flash[:notice] = ‘Error’  
render :action =\> ‘index’  
end  
end

#----model  
file\_column :image

---

<div class="post-metadata">

**Author:** ![anabia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/35a633/32.png) [@anabia](https://www.ruby-forum.com/u/anabia)\
**Post date:** [May 28, 2006, 8:56pm UTC](https://www.ruby-forum.com/t/file-column-trouble-advice-needed/61844/4 "2006-05-28T20:56:03Z")

</div>

You’re probably missing the actual ‘save’ logic in your ArtImage class.

Files inside ‘tmp’ directory are only kept between failed submissions,  
so if you submit the form and everything goes through, at the end of the  
transaction the tmp folder should be empty. (Which is what seems to be  
happening in your case). Make sure your save action actually saves the  
uploaded file somewhere.

OR, just to double check this theory, add a ‘mandatory’ field, and leave  
it blank… Then upload/submit the form with the file and check if you  
get something in the tmp folder.

Ilya

---

<div class="post-metadata">

**Author:** ![anabia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/35a633/32.png) [@anabia](https://www.ruby-forum.com/u/anabia)\
**Post date:** [May 28, 2006, 9:42pm UTC](https://www.ruby-forum.com/t/file-column-trouble-advice-needed/61844/5 "2006-05-28T21:42:26Z")

</div>

ok, iÂ´ve added: validates\_presence\_of :image  
to my model, and now everytime i try to upload an image i get the  
“Error” message from the controller action(when try to save) so im  
guessing that the file\_column\_field arenÂ´t passing any parameters to  
the controller but i cant figure out why, this code workedÂ¡ and suddenly  
without any changes stop to work, im really getting upset with this no  
error signs, no rails exceptions, simply does nothing ☹
