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.

ActiveRecord::Base#has_errors?

#41

I really hate typing unless @foo.errors.blank? when I really mean if @user.has_errors? and thought this might make a good patch on Rails. Calling #invalid? actually clears the errors and redoes the validation which isn't the behavior I want here. I just want to know that the object has errors.

I didn't add tests because it seems a really simple patch and it would probably require mocha to assert that the validations don't get run. I'm completely open to writing tests if need be though.

Reported by RSL · April 23rd, 2008 @ 01:48 AM

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

Activity

  1. RSL
    RSL

    Adding patch. [I thought I just did that.]

    April 23rd, 2008 @ 01:51 AM

  2. josh
    josh
    • State changed from new to invalid

    We are actually moving in the opposite direction, Errors will soon become more hash like. So #invalid? will be replaced by errors.any?.

    April 27th, 2008 @ 06:32 PM

  3. Jeff Kreeftmeijer
    Jeff Kreeftmeijer
    • Tag cleared.
    • Importance changed from to Low

    Automatic cleanup of spam.

    November 7th, 2010 @ 04:52 PM