Sha256: 21a7f2c692a2d0e5abcef003e92d042ee4243367f0ff5f42ea9b5fd37665a6cc

Contents?: true

Size: 575 Bytes

Versions: 3

Compression:

Stored size: 575 Bytes

Contents

module ConcertoWeather
  class SearchController < ConcertoWeather::ApplicationController
    def find_city
      @results = getOpenWeatherCities(params[:q])

      respond_to do |format|
        format.js { render json: @results }
      end
    end

    private
      def getOpenWeatherCities(query)
        require 'net/http'
        require 'json'

        appid = ConcertoConfig["open_weather_map_api_key"]
        url = "http://api.openweathermap.org/data/2.5/find?q=#{query}&type=like&mode=json&appid=#{appid}"
        return Net::HTTP.get(URI(url))
      end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
concerto_weather-0.5 app/controllers/concerto_weather/search_controller.rb
concerto_weather-0.4 app/controllers/concerto_weather/search_controller.rb
concerto_weather-0.3.2 app/controllers/concerto_weather/search_controller.rb