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.

rails 3: errors to_xml missing type="array" attribute in xml element

#5282

respond_with used to output this on errors:

   <?xml version="1.0" encoding="UTF-8"?>
   <errors type="array">
     <error>Name is invalid</error>
   </errors>

with rails3 edge it's now giving this:

   <?xml version="1.0" encoding="UTF-8"?>
   <errors>
     <error>Name is invalid</error>
   </errors>

Note that if you put these through Hash.from_xml(...) then the first returns:

   {"errors"=>["Owner is invalid"]}

while the seconds returns:

   {"errors"=>{"error"=>"Owner is invalid"}}

I believe ActiveResource expects the first variant.

Reported by Lawrence Pit · August 3rd, 2010 @ 08:07 AM

State: invalid
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Neeraj Singh
    Neeraj Singh
    • Importance changed from to Low

    At the top of ActiveResource base_errors_test.rb following is what we have

      def setup
        ActiveResource::HttpMock.respond_to do |mock|
          mock.post "/people.xml", {}, %q(<?xml version="1.0" encoding="UTF-8"?><errors><error>Age can't be blank</error><error>Name can't be blank</error><error>Name must start with a letter</error><error>Person quota full for today.</error></errors>), 422, {'Content-Type' => 'application/xml; charset=utf-8'}
          mock.post "/people.json", {}, %q({"errors":["Age can't be blank","Name can't be blank","Name must start with a letter","Person quota full for today."]}), 422, {'Content-Type' => 'application/json; charset=utf-8'}
        end
      end
    

    Notice there is no 'type=array'

    I guess ActiveResource works fine without 'type=array'.

    August 3rd, 2010 @ 09:47 AM

  2. Neeraj Singh
    Neeraj Singh
    • State changed from new to invalid

    August 4th, 2010 @ 05:26 AM