This project is archived and is in readonly mode.

#1717 new
Matthew Moore

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

Reported by Matthew Moore | January 9th, 2009 @ 09:27 AM | in 3.x

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?
, options), request_body, self.class.headers)
, options), request_body, self.class.headers)

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

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?

Comments and changes to this ticket

  • Ryan Bigg

    Ryan Bigg April 11th, 2010 @ 02:51 AM

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

  • Jeremy Kemper

    Jeremy Kemper May 4th, 2010 @ 06:48 PM

    • Milestone changed from 2.x to 3.x
  • Dan Pickett

    Dan Pickett May 9th, 2010 @ 06:15 PM

    • Tag changed from activeresource, custommethods to activeresource, bugmash, custommethods
  • Jeff Kreeftmeijer

    Jeff Kreeftmeijer October 19th, 2010 @ 07:09 AM

    • Tag cleared.
    • Importance changed from “” to “Low”

    Automatic cleanup of spam.

  • 2kan

    2kan February 3rd, 2011 @ 10:52 AM

    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):

    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.

  • kevinwu007

    kevinwu007 February 25th, 2011 @ 06:09 AM

    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.

  • bingbing
  • bingbing
  • JacelynCecot

    JacelynCecot May 20th, 2011 @ 06:03 AM

    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

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>