refactor to remove rescue

Umar M. Sheikh %!s(int64=11) %!d(string=hace) años
padre
commit
87293e2788
Se han modificado 1 ficheros con 1 adiciones y 1 borrados
  1. 1 1
      app/models/agent.rb

+ 1 - 1
app/models/agent.rb

@@ -60,7 +60,7 @@ class Agent < ActiveRecord::Base
60 60
   }
61 61
 
62 62
   def credential(name)
63
-    user.user_credentials.where(:credential_name => name).limit(1).first.credential_value rescue nil
63
+    user.user_credentials.where(:credential_name => name).first.try(:credential_value) || nil
64 64
   end
65 65
 
66 66
   def check