title: Rails loop through records in model
body: <p>I have 2 hstore columns (<code>parameters</code> and <code>keys</code>) defined in my PostgeSQL database. I want to get a list of keys and have defined a method for it in the model:</p>
  
  <pre><code>def self.keys_list
    logs = self
    list = Log.column_names - %w{id parameters extras}
    logs.each do |log|
      log.parameters.present? ? list &lt;&lt; log.parameters.keys : list &lt;&lt; []
      log.extras.present? ? list &lt;&lt; log.extras.keys : list &lt;&lt; []
    end
    list = list.flatten.uniq
    return list
  end
  </code></pre>
  
  <p>But when I try using it, I get the following error:</p>
  
  <pre><code>NoMethodError: undefined method `each' for #&lt;Class:0x00000004b630b0&gt;
  </code></pre>
  
  <p>Can anyone suggest where the error is or how to do it some other way?</p>