I am getting error undefined method `id' for nil:NilClass. I need to find id of oidValue.if id is nil for oidValue and i need to search oid2 table for get oidValue.How to check nil here.Below code is i am using.Not working if oidId is nil.
oidId = Oid1.find_by(oid: oidvalue).id.to_s
if oidId.nil?
oidId = Oid2.find_by(oid: oidvalue).id.to_s
end
Aucun commentaire:
Enregistrer un commentaire