This project is archived and is in readonly mode.
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
-
Ryan Bigg June 12th, 2010 @ 03:29 AM
- State changed from new to needs-more-info
Please form this into a patch with failing test case + fix, thanks.
-
ronin-34500 (at lighthouseapp) June 12th, 2010 @ 06:02 AM
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.
-
Ryan Bigg June 12th, 2010 @ 06:06 AM
- State changed from needs-more-info to invalid
Done! Thanks Robby!
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>