The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Fixing multipart POST in Rails

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Guy Naor

Posts: 104
Nickname: familyguy
Registered: Mar, 2006

Guy Naor is one of the founders of famundo.com and a long time developer
Fixing multipart POST in Rails Posted: May 30, 2006 4:48 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Guy Naor.
Original Post: Fixing multipart POST in Rails
Feed Title: Famundo - The Dev Blog
Feed URL: http://devblog.famundo.com/xml/rss/feed.xml
Feed Description: A blog describing the development and related technologies involved in creating famundo.com - a family management sytem written using Ruby On Rails and postgres
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Guy Naor
Latest Posts From Famundo - The Dev Blog

Advertisement

Our API is REST based, and so we need all the REST verbs to work. Unfortunately Rails doesn't work correctly with multipart PUT submits. The fix is very simple, and it's a one line change in the file actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb:

--- actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb       (revision 4380)
+++ actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb       (working copy)
@@ -15,7 +15,7 @@
         method = :get
       end

-      if method == :post && (boundary = multipart_form_boundary)
+      if ((method == :post) || (method == :put)) && (boundary = multipart_form_boundary)
         @multipart = true
         @params = read_multipart(boundary, Integer(env_table['CONTENT_LENGTH']))
       else

The only change is adding the :put method to the if that makes the params into multiparams.

I'm posting this as a bug with the patch and the related tests to the Rail trac. Hopefuly it'll be included in a coming release of Rails.

Read: Fixing multipart POST in Rails

Topic: Shopify Profile Previous Topic   Next Topic Topic: Web 2.0 (TM) alternatives

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use