title: Value of key for Model object gained dynamically
body: <p>I'm trying to gain a value from an associated table linked via a field in a table using the following (where i is created in an <code>each</code> loop):</p>
  
  <pre><code>value = current_user.question["convq#{i}"].id
  </code></pre>
  
  <p>My table has references from the <code>Questions</code> table to a <code>Questionsbank</code> table in the form of columns named convq1_id, convq2_id ... convq3_id.</p>
  
  <p>I simply want to cycle through each field in <code>Questions</code> and gain the <code>questionbank.text</code> field.</p>
  
  <p>Sadly, the above will only give me the physical value in the question table field not a link to the associated record using the following code:</p>
  
  <pre><code>(1...9).each do |i|
    value = current_user.question["convq#{i}"].id
  end
  </code></pre>
  
  <p>Can anyone let me know how I can cycle through table and gain the associated 'id' or text value of the referenced record?</p>
  
  <p>Thanks in advance.</p>
  
  <p>Each model is set up as:</p>
  
  <pre><code>class Question &lt; ActiveRecord::Base
  
    belongs_to :user
    belongs_to :convq1, :class_name =&gt; 'Questionbank'
    belongs_to :convq2, :class_name =&gt; 'Questionbank'
    belongs_to :convq3, :class_name =&gt; 'Questionbank'
    belongs_to :convq4, :class_name =&gt; 'Questionbank'
    belongs_to :convq5, :class_name =&gt; 'Questionbank'
    belongs_to :convq6, :class_name =&gt; 'Questionbank'
    belongs_to :convq7, :class_name =&gt; 'Questionbank'
    belongs_to :convq8, :class_name =&gt; 'Questionbank'
    belongs_to :convq9, :class_name =&gt; 'Questionbank'
    has_many :questionbanks
  
  end
  </code></pre>
  
  <p>and ...</p>
  
  <pre><code>class Questionbank &lt; ActiveRecord::Base
  
    has_many :likes
    has_many :questions
  
  end
  </code></pre>