I’m using Rails3 and have created a simple document table with a document_name (string) and document (blob) column and a few other columns for metadata. I’ve added
<%= f.label :document %><br />
<%= f.file_field :document %>
to the _form.html.erb partial. The model is unchanged (generated via rails g scaffold…)
Update and New actions works fine for all columns but the uploaded document is not saved into the document column. Instead, the name of the uploaded document is saved to the document column (not the file content).
How can I write the uploaded binary data to the document field and the uploaded file name to the document_name column?
My guess is that you forgot to set
:multipart=>truein the form tag.Could you post the whole “new” form?