jeudi 25 juin 2015

How to fix Ruby on Rails obj != nil error

I'm trying to ensure that an object is not nil in Ruby on Rails and I'm getting this error:

Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id

This is what the object looks like in the debugger (it is not nil):

enter image description here

How do I correctly check for nil in this case? All cases?

I've found some similar posts but not this specific case: Check for nil gives error, and Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id.

How do I correctly check for nil in this case?

Aucun commentaire:

Enregistrer un commentaire