title: Showing HTTP response in Rails - undefined method `each' for nil:NilClass
body: <p>I'm using the HTTParty gem, Rails 5, and the "httplog" gem.</p>
  
  <p>I traced my HTTP request using the "httplog" gem and I received the correct JSON response. Due to this, I believe that my issue is occurring in my view. I am accessing the API properly from the model. I am utilizing it correctly in the controller as per the HTTP log. I'm just flubbing up somewhere between my view and controller.</p>
  
  <p>I'm getting an <strong>"undefined method `each' for nil:NilClass"</strong> error when accessing the API.</p>
  
  <p>Here is an example response from the API:</p>
  
  <pre><code>{
      "result_count": 8132,
      "page_size": 250,
      "current_page": 1,
      "total_pages": 33,
      "api_call_credits": 1,
      "data": [
          {
              "ticker": "A",
              "name": "Agilent Technologies Inc",
              "lei": "QUIX8Y7A2WP0XRMW7G29",
              "cik": "0001090872",
              "latest_filing_date": "2017-02-06"
          }
  </code></pre>
  
  <p>Here is my model:</p>
  
  <pre><code>class Finance &lt; ApplicationRecord
    include HTTParty
  
    def self.response
      auth = {
      username: "username",
      password: "password"
      }
      options = { basic_auth: auth }
      data_url = "https://api.intrinio.com/companies?ticker=AAPL"
      HTTParty.get(data_url, options)
      end
  end
  </code></pre>
  
  <p>My controller:</p>
  
  <pre><code>class FinancesController &lt; ApplicationController
    def index
      @response = Finance.response
    end
  end
  </code></pre>
  
  <p>My View:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;% @response["data"].each do |data| %&gt;
      &lt;p&gt;&lt;%= data["name"]%&gt;&lt;/p&gt;
      &lt;p&gt;&lt;%= data["ticker"]%&gt;&lt;/p&gt;
  &lt;% end %&gt;</code></pre>
  </div>
  </div>
  </p>