mardi 14 juillet 2020

Rails 3 throwing NoMethodError for nil:NilClass when using try

The below code is throwing "undefined method `name' for nil:NilClass". I've been trying to understand this but everything I read says that try should never throw a NoMethodError when the receiving object is nil.

is_null = summary.alert_type.try(:name) == :null

Aucun commentaire:

Enregistrer un commentaire