EMS
unread,Dec 18, 2008, 6:17:32 PM12/18/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Streamlined
I have added upload_column into my application so I can do a simple
file upload. Following along with everything I've seen here, in the
upload_column site, and the streamlinedframework docs, I have done the
following:
1) Added my upload column to my model:
upload_column :sFileName,
:root_path => FILE_UPLOAD_CFG[RAILS_ENV][:file_upload_root],
:store_dir => FILE_UPLOAD_CFG[RAILS_ENV][:file_upload_path]
2) Added the magic columns to my migration and migrated the database.
# Table already contains sFileName of type :string
def self.up
add_column :tblMain, :sFileName_mime_type, :string
add_column :tblMain, :sFileName_filesize, :integer
end
3) Altered the _form.rhtml to handle the field
<% model_ui.edit_columns.each do |column| %>
<% if column.name.to_sym == :sFileName %>
<tr id="sl_field_media">
<td class="sl_edit_label"><label for=<%="#{form.object_name}
_sFileName"%>><%= column.human_name %></label></td>
<td class="sl_edit_value"><%= upload_column_field
form.object_name, 'sFileName' %></td>
</tr>
<% elsif column.is_displayable_in_context?(self,
@streamlined_item) %>
<%= column.render_tr_edit(self, @streamlined_item) %>
<% end %>
<% end %>
4) Made my new.rhtml and edit.rhtml use multipart
from new.rhtml
<% options[:html] = {:onsubmit=>'Streamlined.Form.submit(this);
return false;', :multipart => true} %>
from edit.rhtml
<% options[:html] = {:onsubmit=>'Streamlined.Form.submit(this);
return false;', :multipart => true} %>
Now when I run my app, I get the form (and viewing the form source, I
can see that the fields appear to match up against the database, and
that the form is marked for 'multipart/form-data'
But when I click the "Create" button, I receive an Upload Not
Multipart Error from uploaded_file.rb(72)
"Do not know how to handle a string with value 'testfile.csv' that was
uploaded. Check if the form's encoding has been set to 'multipart/form-
data'"
So my questions are:
1) Has anyone successfully integrated a file upload using
upload_column? If so, can you send/post an example for download so I
can see what is missing?
2) Has anyone been successful with another file upload tool
(attachment_fu, paperclip, etc...) and if so, can you post an example
for download so I can see what is missing?
Or, if something prohibits you from posting an example, can you
provide some hints about what steps have been missed?
Sincereley,
EMS