Welcome Guest | Login

form_for not generating POST in production

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

Is this a FastCGI app?  We've seen problems with RESTful apps and FastCGI.  If that's the case then have support bump you up to Mongrel for free to see if it fixes it.

If its not the case then I'm not sure off the top of my head what it might be.  This will likely take support getting their hands into testing it with you.

2008-03-31 10:00 PM

Yes, this is a FastCGI app. I'm currently working with support to setup mongrel for this application. Can you point me towards something explaining the FastCGI bug? I'd like to better understand it so I can avoid the issue going forward.

Thank you!

2008-03-31 10:56 PM

We're still not exactly sure, but it has something to do with the way that Apache and FastCGI interact with each other that is preventing/modifying Rails RESTful calls.  Until a workaround is found we're giving free Mongrels away for those who need it for their apps.  

2008-04-01 12:30 AM


Hello Guest! In order to post you must be an active client with us, please log in or sign up today!