Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ActiveResource::CustomMethods#put should behave like #post for body encoding

#1717

If you compare the two methods in ActiveResrouce::CustomMethods, you see:



      def post(method_name, options = {}, body = nil)
        request_body = body.blank? ? encode : body
        if new?
          connection.post(custom_method_new_element_url(method_name, options), request_body, self.class.headers)
        else
          connection.post(custom_method_element_url(method_name, options), request_body, self.class.headers)
        end
      end

      def put(method_name, options = {}, body = '')
        connection.put(custom_method_element_url(method_name, options), body, self.class.headers)
      end

I can't figure out for the life of me why the post method has


request_body = body.blank? ? encode : body

but put doesn't.

Should I add that line to put?

Reported by Matthew Moore · January 9th, 2009 @ 09:27 AM

State: new
Milestone: 3.x
Assigned to: Michael Koziarski Michael Koziarski
Importance: Low

Activity

  1. Ryan Bigg
    Ryan Bigg

    Could you please make a test case & patch for this?

    April 11th, 2010 @ 02:51 AM

  2. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  3. Dan Pickett
    Dan Pickett
    • Tag changed from activeresource, custommethods to activeresource, bugmash, custommethods

    May 9th, 2010 @ 06:15 PM

  4. Jeff Kreeftmeijer
    Jeff Kreeftmeijer
    • Tag cleared.
    • Importance changed from to Low

    Automatic cleanup of spam.

    October 19th, 2010 @ 07:09 AM

  5. 2kan
    2kan

    It is simple. This methods are designed (as I understand) to invoke REST methods. For example you can use post method to create a new object. And you can not to pass a body with new object data as argument, but just call a post method on a new object like it is done in test_custom_new_element_method (custom_method_test.rb): ryan.post(:register)

    Encode will just serialize ryan object into some appropriate representation and passe it to the post method as a param like you just have submitted a form.

    But since this designed to invoke REST methods you can't use put for creating a new object and if you don't send a body it means that you don't want to send a body so encode is not needed here in the put method.

    So I think this ticket should be closed.

    February 3rd, 2011 @ 10:52 AM

  6. kevinwu007
    kevinwu007

    Today is fine. My mother said to me:"Get saints super bowl jersey up please!And look out of the window. What a fine day! Let's go to park,"It was really a good day, So my mother, my classmate and I went to the park. We took some foods in my schoolbag. On the way to the park. I saw the blue sky with snow-white clouds. I saw pear trees and some apple trees and so on. Below the authentic nfl jerseys trees, there are several kinds of flowers. It's colorful, blue, red, yellow, pink, purple, orange and white. I saw some peyton manning jersey balloons and butterflies in the sky. I ate popcorn, cornflakes, banana and lollipop. They were wonderful. In the afternoon, we went to colts nfl jerseys the zoo. I visited the birds, mice, cats, dogs, budgies, hamsters, rabbits and so on.

    February 25th, 2011 @ 06:09 AM

  7. bingbing
  8. bingbing
  9. JacelynCecot
    JacelynCecot

    Thanks for a marvelous posting! I quite enjoyed reading it, you can be a great author.I will ensure that I bookmark your blog and may come back from now on. I want to encourage you to definitely continue your great work, have a nice weekend! Chicago SEO | Jacelyn Cecot

    May 20th, 2011 @ 06:03 AM