This project is archived and is in readonly mode.

#5282 ✓invalid
Lawrence Pit

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

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

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.

Comments and changes to this ticket

  • Neeraj Singh

    Neeraj Singh August 3rd, 2010 @ 09:47 AM

    • 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'.

  • Neeraj Singh

    Neeraj Singh August 4th, 2010 @ 05:26 AM

    • State changed from “new” to “invalid”

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>

Pages