title: Rails - mixing of 'send' and 'try'
body: <p>I have an object which could be nil. In the next line i am getting any one of the object's argument dynamically based on some condition. I was using object.try() with if else block. Now I want to use send() so that I can achieve some efficient code. </p>
  
  <pre><code>form_name = 'parent' ( received from argument )
  mes_record = Mark.first ( this can be nil )
  
  if x == condition_1
      mes_record.parent
  elsif x == condition_2
      mes_record.brother
  elsif x == condition_3
      mes_record.sister
  else
      mes_record.father
  end
  </code></pre>
  
  <p>Now I want to avoid the if else ladder and use send.</p>
  
  <pre><code> if mes_record.present?
        mes_record.send("#{form}")
   else
        mes_record = 'not available'
   end
  </code></pre>
  
  <p>I am searching for something like try.</p>
  
  <pre><code>   mes_record.try("dynamically substitute the attribute name here.") || 'not available'
  </code></pre>
  
  <p>Any help?!</p>