title: Get attribute of ActiveRecord by name
body: <p>I have a partial, that will be used in many places of a project.</p>
  
  <p>It renders items, related to specified tag, like:</p>
  
  <pre><code>@tag.articles.each do |a|
      # render articles
  end
  </code></pre>
  
  <p>I need this partial to render not only articles, but any other items, associated with tags.</p>
  
  <p>So, this partial has one parameter <strong>association_name</strong> and looks like this:</p>
  
  <pre><code>@tag[association_name].each do |a|
      # render articles
  end
  </code></pre>
  
  <p>I call this partial in following ways:</p>
  
  <pre><code># to render articles
  render :partial =&gt; "items", :locals =&gt; {:association_name =&gt; "articles"}
  
  # to render videos
  render :partial =&gt; "items", :locals =&gt; {:association_name =&gt; "videos"}
  
  # etc.
  </code></pre>
  
  <p>The problem is - i cannot refer fields of Article model in a way:</p>
  
  <pre><code>@article[association_name]
  </code></pre>
  
  <p>How to do it and why it does't works ?</p>