This project is archived and is in readonly mode.
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?
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?
Comments and changes to this ticket
-
Dan Pickett May 9th, 2010 @ 06:15 PM
- Tag changed from activeresource, custommethods to activeresource, bugmash, custommethods
-
Jeff Kreeftmeijer October 19th, 2010 @ 07:09 AM
- Tag cleared.
- Importance changed from to Low
Automatic cleanup of spam.
-
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): 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.
-
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.
-
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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>