Hi, I''m just trying out Sebastian''s file_upload plugin, but I''m having problems - bound to be my fault! I can''t search gmane at the moment for examples that I''m sure have been recently posted :-( I have a MySQL table "scripts" with a field "filename varchar(255) not null, and a basic scaffold''d set of files for model "Script". I''ve installed file_upload using "script/plugin install", I think it caught rev 58. In app/models/script.rb I''ve added "file_column :filename", and in app/views/scripts/_form.rhtml I''ve changed the generated text_field into a file_column_field - the form looks fine, I get an Browse button. I can use the Browse button to select a file ... but ... When I try to submit the form, I get a crash : TypeError in Scripts#create Do not know how to handle a string with value ''jim.jpg'' that was passed to a file_column. Check if the form''s encoding has been set to ''multipart/form-data''. I guess I must have missed a trick somewhere else. There are no records in the table (to be expected, but worth checking) Where should I be looking next to figure this out? -jim
For once thre''s acutally a sane error message: Check if the form''s encoding has been set to ''multipart/form-data''. Did you check that?>When I try to submit the form, I get a crash : > TypeError in Scripts#create > > Do not know how to handle a string with value ''jim.jpg'' that was passed > to a file_column. Check if the form''s encoding has been set to > ''multipart/form-data''. > >I guess I must have missed a trick somewhere else. There are no records >in the table (to be expected, but worth checking) > >Where should I be looking next to figure this out? > >-jim >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/railsMikkel Bruun www.strongside.dk - Football Portal(DK) nflfeed.helenius.org - Football News(DK) ting.minline.dk - Buy Old Stuff!(DK) -- Posted with http://DevLists.com. Sign up and save your time!
On Tue, Mar 07, 2006 at 09:58:56AM -0000, Mikkel Bruun wrote:> For once thre''s acutally a sane error message::-)> Check if the form''s encoding has been set to ''multipart/form-data''. > Did you check that?Initially no - I had incorrectly assumed that declaring file_column would have fixed up the form definition, but I guess it can''t override what was in the template ... So, I tried to set :multipart => true in the new.rhtml, and still had problems. A trawl through the docs revealed my error - where the scaffold had created a call to start_form_tag with only one parameter, I''d just added the :multipart to the end ... whereas the extended form only works for me when the whole thing is fully bracketed :- Scaffold created: <%= start_form_tag :action => ''create'' %> I tried (and failed with): <%= start_form_tag :action => ''create'', :multipart => true %> Everything works fine with: <%= start_form_tag ({:action => ''create''}, {:multipart => true}) %> -jim