This project is archived and is in readonly mode.

#6014 ✓stale
Frank Prößdorf

deserialize error messages directly from error hash instead of an array of messages

Reported by Frank Prößdorf | November 19th, 2010 @ 03:44 PM

Currently errors are interpreted and received in the following format:

    <?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>
    {"errors":["Age can't be blank","Name can't be blank","Name must start with a letter","Person quota full for today."]}

With the attached patch the following will be correctly interpreted:

    <?xml version="1.0" encoding="UTF-8"?><errors><age type="array"><age>can't be blank</age></age><name type="array"><name>can't be blank</name><name>must start with a letter</name></name><base type="array"><base>Person quota full for today.</base></base></errors>
    {"errors":{"age":"can't be blank","name":["can't be blank","must start with a letter"],"base":"Person quota full for today."}}

We feel that this is a more flexible and direct solution; the code to interpret this is more readable and shorter and it allows for such things as translating error messages in the backend and being able to still associate them with the correct attribute in the frontend.

One thing that needs fixing before applying this is #5615, which will then allow to have multiple error messages on one attribute.

Comments and changes to this ticket

  • Thilo Utke

    Thilo Utke November 19th, 2010 @ 04:39 PM

    removed whitespace from diff.

  • Sebastian Cohnen
  • rails

    rails February 20th, 2011 @ 12:00 AM

    • State changed from “new” to “open”

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

  • rails

    rails February 20th, 2011 @ 12:00 AM

    • State changed from “open” to “stale”

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>

Attachments

Pages