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.

Improved AR::Errors API to get to the Error objects

#3186

Currently the only way to get to the raw Error objects if via model.errors.each_error. This patch provides a nicer API for the usual cases where you just want to check the presence of a specific error.

In addition, the testsuite didn't have a test that tested that errors.on would return an array of messages. This patch also adds tests for that.

Reported by Lawrence Pit · September 11th, 2009 @ 07:20 AM

State: stale
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Lawrence Pit
    Lawrence Pit

    where you just want to check the presence of a specific error.

    what I mean is, in my specs I'd like to do:

       model.error_on(:title).type.should == :invalid
       model.error_on(:salary).type.should == :too_low
    

    PS. having +type+ as an attr_accessor of the Error object is not helpful.. but that's another ticket.

    September 11th, 2009 @ 07:25 AM

  2. Lawrence Pit
  3. Lawrence Pit
    Lawrence Pit
    • Tag changed from 2-3-stable, active_record, i18n to 2-3-stable, active_record, i18n, patch

    September 24th, 2009 @ 12:48 PM

  4. Rohit Arondekar
    Rohit Arondekar
    • State changed from new to stale
    • Importance changed from to

    Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.

    October 6th, 2010 @ 06:43 AM