title: HTTParty undefined method '+' for nil:NilClass
body: <p>Using <code>HTTParty</code> gem to connect to a weather API I have the following method:</p>
  
  <pre><code>def weather_search
    @city_name = params[:city_name]
    url = URI.encode("api.openweathermap.org/data/2.5/weather?q=#{@city_name}&amp;APPID=#{API_TOKEN}")
    @search_result = HTTParty.get(url)
  end
  </code></pre>
  
  <p>the gem is installed.</p>
  
  <p>Using postman I can reach the API without problems with the following url</p>
  
  <pre><code>api.openweathermap.org/data/2.5/weather?q=banfield&amp;APPID=xxxxxxxxxxxxxxx
  </code></pre>
  
  <p>However in my rails 4 app it the same url throws the error</p>
  
  <p><code>undefined method '+' for nil:NilClass</code> on the line where I declare </p>
  
  <p><code>@search_result = HTTParty.get(url)</code></p>
  
  <p>I found <a href="https://stackoverflow.com/questions/29985406/ruby-no-method-error-with-httparty">this</a> and <a href="https://forum.upcase.com/t/authentication-through-an-api-that-uses-devise/58" rel="nofollow noreferrer">this other</a> post on the subject but both are of no help.</p>
  
  <p>Stack Trace:</p>
  
  <pre><code>Started POST "/search_city_weather" for 127.0.0.1 at 2016-03-30 23:50:13 +0100
  Processing by WeatherChecksController#weather_search as HTML
    Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "city_name"=&gt;"banfield", "commit"=&gt;"Search"}
  api.openweathermap.org/data/2.5/weather?q=banfield&amp;APPID=xxxxxxxxxxxxxxxxxx
  Completed 500 Internal Server Error in 11ms
  NoMethodError (undefined method `+' for nil:NilClass):
    app/controllers/weather_checks_controller.rb:24:in `weather_search'
    Rendered /home/xxxx/.rvm/gems/ruby-2.2.2/gems/actionpack-4.1.4/lib/action_dispatch/middleware/templates/rescues/_source.erb (1.3ms)
    Rendered /home/xxxx/.rvm/gems/ruby-2.2.2/gems/actionpack-4.1.4/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.1ms)
    Rendered /home/xxxx/.rvm/gems/ruby-2.2.2/gems/actionpack-4.1.4/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.3ms)
    Rendered /home/xxxx/.rvm/gems/ruby-2.2.2/gems/actionpack-4.1.4/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (22.6ms)
  </code></pre>
  
  <p>Any help will be much appreciated.</p>