This project is archived and is in readonly mode.

#3752 ✓invalid
ronin-34500 (at lighthouseapp)

error_wrapping in active_model_helper and nil errors

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

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?

Comments and changes to this ticket

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=""></a>

People watching this ticket