title: How to use a variable as object attribute in rails?
body: <p>I have a PaymentDetail model with attribute 'home_address_country', so i can use</p>
  
  <pre><code>    @payment_detail.home_address_country //where @payment_detail is object of that model.
  </code></pre>
  
  <p>I want to use something like this:---</p>
  
  <pre><code>country_attribute=address_type+"_address_country"  //where address type is equal to 'home'
   @payment_detail."#{country_attribute}" 
  </code></pre>
  
  <p><strong>Means attribute name is stored in a variable. How can i do this?</strong></p>
  
  <p><strong>EDIT</strong>   </p>
  
  <pre><code>country_attribute=address_type+"_address_country"
  country_list=Carmen::country_names
  eval("@#{country_attribute} = #{country_list}")
  </code></pre>