Rails 4- iterating over RDF::Query::Solutions & RDF::Query::Solution
<p>I have a small Rails app that processes some sparql query results. 
The sparql creates a solutions set <code>@solutions_array</code> of 6859 solutions. The solutions set is of class RDF::Query::Solutions, within it are the 6859 instances of class RDF::Query::Solution. Each RDF::Query::Solution contains two variables, :unit and :battle. According to the documentation these should be available as solution.unit &amp; solution.battle. When i use <code>@solutions_array.first.unit</code> i get exactly the result expected. Every thing above the dashes in my output works as expected.</p>

<blockquote>
  <p>Discovered Concepts</p>
  
  <p>Class: class RDF::Query::Solutions</p>
  
  <p>Count: class 6859</p>
  
  <p>First Query Solution:</p>
  
  #
  
  <p>URI:...resource/3rd_Guards_Infantry_Division_(German_Empire)>,
  :battle=>#})></p>
  
  <p>First Unit:
  ...resource/3rd_Guards_Infantry_Division_(German_Empire)</p>
  
  <hr>
  
  <p>Class: RDF::Query::Solution</p>
  
  <p>Inspect:</p>
  
  #
  
  <p>URI:...resource/3rd_Guards_Infantry_Division_(German_Empire)>,
  :battle=>#})></p>
  
  <p>Class: RDF::Query::Solution</p>
  
  <p>Inspect:</p>
  
  #
  
  <p>URI:...resource/3rd_Guards_Infantry_Division_(German_Empire)>,
  :battle=>#})></p>
</blockquote>

<p>The output is produced by these few lines:</p>

<pre><code>&lt;div class="span3 offset1"&gt;
      &lt;h2&gt; Discovered Concepts &lt;/h2&gt;
            &lt;P&gt;Class:  class &lt;%= @solutions_array.class %&gt; &lt;/p&gt; 
            &lt;P&gt;Count:  class &lt;%= @solutions_array.count %&gt; &lt;/p&gt; 
            &lt;p&gt;First Query Solution: &lt;%= @solutions_array.first.inspect %&gt;&lt;/p&gt;
            &lt;p&gt;First Unit: &lt;%= @solutions_array.first.unit %&gt;&lt;/p&gt;
            &lt;p&gt;-------------------------------------------------&lt;/p&gt;        
            &lt;%= @solutions_array.each do |solution| %&gt;
              &lt;p&gt;Class: &lt;%= solution.class %&gt;&lt;/p&gt;
              &lt;p&gt;Inspect: &lt;%= solution.inspect %&gt;&lt;/p&gt;

            &lt;% end %&gt;
</code></pre>

<p>Now, when i try to access my variables when iterating over the solutions, {|solution| puts solution.battle } throws the error 'method unknown'. When i try the same using irb i get no error. My code looks as follows (same as above, except for the single added line <code>&lt;p&gt;Unit: &lt;%= solution.unit %&gt;&lt;/p&gt;</code>:</p>

<pre><code>&lt;div class="span3 offset1"&gt;
      &lt;h2&gt; Discovered Concepts &lt;/h2&gt;
            &lt;P&gt;Class:  class &lt;%= @solutions_array.class %&gt; &lt;/p&gt; 
            &lt;P&gt;Count:  class &lt;%= @solutions_array.count %&gt; &lt;/p&gt; 
            &lt;p&gt;First Query Solution: &lt;%= @solutions_array.first.inspect %&gt;&lt;/p&gt;
            &lt;p&gt;First Unit: &lt;%= @solutions_array.first.unit %&gt;&lt;/p&gt;
            &lt;p&gt;-------------------------------------------------&lt;/p&gt;        
            &lt;%= @solutions_array.each do |solution| %&gt;
              &lt;p&gt;Class: &lt;%= solution.class %&gt;&lt;/p&gt;
              &lt;p&gt;Inspect: &lt;%= solution.inspect %&gt;&lt;/p&gt;
              &lt;p&gt;Unit: &lt;%= solution.unit %&gt;&lt;/p&gt;
            &lt;% end %&gt;
</code></pre>

<p>Running this code results in:    </p>

<pre><code>   &gt; NoMethodError in Pages#extract

    &gt; Showing/.../app/views/pages/extract.html.erb where line #20 raised:
    &gt; undefined method `unit' for #&lt;RDF::Query::Solutions:0x007fd17b17bca0&gt;
    &gt; Extracted source (around line #20): 
20   &lt;p&gt;Unit: &lt;%= solution.unit %&gt;
</code></pre>

<p>What's funny is that the error says that "unit" is no method for the class RDF::Query::Solutions...which is in principle true, but the solution.inspect shows that i'm working on an instance of the class RDF::Query::Solution, for which the variable name should be available...</p>

<p>What am i doing wrong ?or is this a bug in RDF.rb ?</p>