Skip to content

Instantly share code, notes, and snippets.

@karlstolley
Created November 8, 2012 21:47
Show Gist options
  • Save karlstolley/4041903 to your computer and use it in GitHub Desktop.
Save karlstolley/4041903 to your computer and use it in GitHub Desktop.
Using Windy in Rails
# snip
gem 'windy' # https://github.com/Chicago/windy
# snip
# app/models/ward.rb
class Ward < ActiveRecord::Base
attr_accessible :name, :wardnumber
def alderman
find_ward.alderman.titleize
end
def alderman_phone
find_ward.ward_phone[0]
end
private
# htai-wnw4 is the ward info identifying URL fragment, e.g.:
# http://data.cityofchicago.org/api/views/htai-wnw4/rows.json
def ward_info
Windy.app_token = "APP-TOKEN-HERE"
Windy.views.find_by_id('htai-wnw4').rows
end
def find_ward
ward_info.find_by_ward(wardnumber.to_s)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment