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.

error_wrapping in active_model_helper and nil errors

#3752

I'm running into an issue with MongoMapper and Rails 3. The problem occurs in actionpack/lib/action_view/helpers/active_model_helper.rb in the error_wrapping method. The problem is that when it gets to "object.errors[@method_name].any?", there are no errors present, and it throws the following error:

You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.any?

I was able to get around this problem by changing that line to this:

if object.respond_to?(:errors) && object.errors.respond_to?(:full_messages) && object.errors.present? && object.errors[@method_name].any?

Reported by ronin-34500 (at lighthouseapp) · January 19th, 2010 @ 10:51 PM

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

Activity

  1. Ryan Bigg
    Ryan Bigg
    • State changed from new to needs-more-info

    Please form this into a patch with failing test case + fix, thanks.

    June 12th, 2010 @ 03:29 AM

  2. ronin-34500 (at lighthouseapp)
    ronin-34500 (at lighthouseapp)

    I've since switched to Mongoid which fully supports Rails 3. MongoMapper only has partial support, so I'm sure this was an issue with that library.

    Please reject the ticket.

    June 12th, 2010 @ 06:02 AM

  3. Ryan Bigg
    Ryan Bigg
    • State changed from needs-more-info to invalid

    Done! Thanks Robby!

    June 12th, 2010 @ 06:06 AM