Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #10635 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

[PATCH] Improve JSON support in ActiveResource custom methods

Reported by: joerichsen Assigned to: core
Priority: normal Milestone: 2.x
Component: ActiveResource Version: edge
Severity: normal Keywords: JSON
Cc:

Description

Doing stuff like

class Person < ActiveResource::Base
  self.site = "http://37s.sunrise.i:3000"
end

will result in

Person.new(:name => 'Ryan).post(:register)  # POST /people/new/register.xml

But if you add a JSON format declaration to the Person class like this

class Person < ActiveResource::Base
  self.site = "http://37s.sunrise.i:3000"
  self.format = :json
end

the result is still

Person.new(:name => 'Ryan).post(:register)  # POST /people/new/register.xml

where one would expect

Person.new(:name => 'Ryan).post(:register)  # POST /people/new/register.json

This patch fixes this problem.

Attachments

make_AR_custom_methods_more_format_agnostic_patch.diff (3.5 kB) - added by joerichsen on 12/28/07 13:30:05.

Change History

12/28/07 13:30:05 changed by joerichsen

  • attachment make_AR_custom_methods_more_format_agnostic_patch.diff added.

12/28/07 13:31:44 changed by joerichsen

  • summary changed from [PATCH] Improve JSON support in AR custom methods to [PATCH] Improve JSON support in ActiveResource custom methods.

12/28/07 15:22:10 changed by chuyeow

Good catch!

+1

This applies well against r8499 (r8500 has a broken test, not due to your patch - will post a fix for that separate issue).

12/28/07 17:04:02 changed by rick

  • status changed from new to closed.
  • resolution set to fixed.

(In [8502]) Support agnostic formats when calling custom methods. Closes #10635 [joerichsen]

12/28/07 17:06:09 changed by technoweenie

Great, keep it coming! I think there's still a bit more work to make json support as simple as xml.

chuyeow: does [8501] fix the problem you were seeing? (something about BasicObject not being defined). If not, please open a new ticket w/ details.

12/28/07 17:08:50 changed by chuyeow

Yup it fixes it, I'd opened a ticket (#10636) but closed it as resolved after I saw your commit.