Created
November 8, 2012 21:47
-
-
Save karlstolley/4041903 to your computer and use it in GitHub Desktop.
Using Windy in Rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# snip | |
gem 'windy' # https://github.com/Chicago/windy | |
# snip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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