- Fatdivot
- Posts: 3
- Starts: 3
- Wiki Edits: 0
I have a very simple file upload procedure that uses attachment_fu. Everything works fine when in development mode on my local machine, but no luck when trying to run on the hostingrails.com server, in production mode. No error message is generated, which made troubleshooting frustrating to say the least. However, I realized earlier that the form in the view is issuing a GET instead of a POST and therefore, running the "index" action, rather than the "create" action. I'm running rails 2.0.2 with restful routing and the latest version of attachment_fu. I also verified method="post" is generated in the form tag on the resulting page. What could be happening on the server that would ignore the post method?
Here's my code:
Model:
class ItemUpload < ActiveRecord::Base
has_attachment :storage => :file_system,
:max_size => 5.megabytes
validates_as_attachment
end
Controller:
def create
@item_upload = ItemUpload.new(params[:item_upload])
if @item_upload.save
if process_import(@item_upload) > 0
redirect_to item_uploads_path
else
redirect_to admin_index_path
end
else
render :action => :new
end
end
View for New action:
<% form_for(:item_upload, :url => item_uploads_path, :html => { :multipart => true }) do |form| %>
<p>
<label for="uploaded_data">Select a file to upload:</label>
<%= form.file_field :uploaded_data %>
</p>
<p>
<%= submit_tag "Upload" %>
</p>
<% end %>
2008-03-31 07:26 PM