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.

Re-add to_xml to ActiveResource

#1011

The method #encode doesn't work on an instance of ActiveResource having other ActiveResource instances in it's attributes.

Example:


  @mum = Parent.find(1)
  @mum.attributes = {"name" => "Mum","children"=> [#<Parent::Child:0x405e8cc ...>,#<Parent::Child:0x405e8cc ...>]}
  @mum.name = "Mom"
  @mum.save
  # => RuntimeError Exception: Not all elements respond to to_xml

Solution:

re-add #to_xml to ActiveResource::Base

Reported by adam.groves (at gmail) · September 10th, 2008 @ 11:25 AM

State: resolved
Milestone: none
Assigned to: Pratik Pratik
Importance: none

Activity

  1. Michael Koziarski
    Michael Koziarski
    • Tag changed from activeresource, bug, patch, tested to activeresource, bug, patch, tested
    • Milestone cleared.

    September 18th, 2008 @ 10:00 AM

  2. rbpandey
    rbpandey

    Created a test and fixed this issue. Please have a look.

    September 23rd, 2008 @ 08:50 PM

  3. Daniel Schierbeck
    Daniel Schierbeck

    Hi rbpandey.

    I've had a quick look at your patch, and it seems like you're using tabs instead of two spaces to indent your code. I believe the Rails coding guidelines say that you've got to use the latter style.

    Otherwise the patch looks good -- please do fix this and resubmit!

    September 23rd, 2008 @ 09:54 PM

  4. rbpandey
  5. rbpandey
  6. Pratik
    Pratik
    • Assigned user set to Pratik
    • State changed from new to incomplete

    Patch is missing the documentation.

    Thanks.

    October 7th, 2008 @ 03:36 PM

  7. Cody Fauser
    Cody Fauser

    Patch updated with documentation for encoding() and to_json().

    October 7th, 2008 @ 05:12 PM

  8. Wesley Moxam
  9. Repository
    Repository
    • State changed from incomplete to resolved

    (from [f2c10f27565318b5efbdc57fb608b2afe9ae445d]) Add ActiveResource::Base#to_xml and ActiveResource::Base#to_json methods. [#1011 Re-add to_xml to ActiveResource state:resolved]

    Signed-off-by: Pratik Naik pratiknaik@gmail.com http://github.com/rails/rails/co...

    October 7th, 2008 @ 05:49 PM