I was using file_column today in Ruby on Rails and ended up with the error:
Do not know how to handle a string with value 'my_fruity_graph.png' that was passed to a file_column. Check if the form's encoding has been set to 'multipart/form-data'.
The problem is obvious.. enctype="multipart/form-data" was not part of the form_tag.
Now how to get that to work.. not so easy. Rails manual might make you think you should do something like:
<%= start_form_tag :action => 'create', :multipart => true %>
Nope.. doesn't work the way it should.. so what do you try next?
<%= start_form_tag { :action => 'create' }, :multipart => true %>
No.
<%= start_form_tag { :action => 'create' }, { :multipart => true } %>
Still doesn't work.
Try this:
<%= start_form_tag ( {:action => 'create' }, :multipart => true) %>
For your edit screens use:
<%= start_form_tag ( {:action => 'update', :id => @product }, :multipart => true ) %>




May 15th, 2006 at 13:16
Thanks, saved me today.
May 24th, 2006 at 18:38
many thanks for :-
'update', :id => @product }, :multipart => true ) %>
works perfectly and saved me a lot of time.
Many thanks again!
May 28th, 2006 at 07:22
Many many thanks for the tip. You really bailed me out!
September 28th, 2006 at 18:25
thanks, I was having the same problem!
January 13th, 2007 at 15:14
half a year later it caught me too... ;-)
Thanks
March 23rd, 2007 at 18:16
Thx, i've been looking for it for a while
April 10th, 2007 at 09:30
Thx so much, was like a panadol for my head.
April 18th, 2007 at 07:20
[...] ; true) especially the exact using of the parentheses is important. This one saved my day: http://ifakedit.com/log/2006/04/25/multipart-in-start_form_tag/ [...]
April 18th, 2007 at 07:20
[...] ; true) especially the exact using of the parentheses is important. This one saved my day: http://ifakedit.com/log/2006/04/25/multipart-in-start_form_tag/ [...]
June 24th, 2007 at 13:17
Thanks, you just saved my arse ;-)
September 24th, 2007 at 11:41
Yes, this was very helpful, thank you.
It's even more difficult if you want to make it work on a page with several forms. Then you need to do it like:
start_form_tag( {:action => 'myaction'}, {:id=>'42', :name=>'myformname', :multipart => true } )
...and woe betide you if you don't get all of the parentheses right... what's even worse is that I haven't managed yet to get this to work with the non-deprecated version .
December 7th, 2007 at 21:45
THANK YOU !!!!!!!
January 16th, 2008 at 23:24
How can I do that with , I just try many ways to make this right (silly question isn't it? :D)
thanks a lot
January 16th, 2008 at 23:33
How can I do that with 'form for' not 'start form tag', I just try many ways to make this right (silly question isn’t it? :D)
thanks a lot
February 4th, 2008 at 09:51
Thanks for the post. Just what I was looking for.
aageboi:
The form_for version would be something like this:
products_path, :html => { :multipart => true } do |f| -%>
(the critical bit is the :html => {:id => 'person_form'})
February 14th, 2008 at 08:58
I try do do that with form_remote_tag .... how i can do that??