Created
March 27, 2009 19:32
-
-
Save mileszs/86843 to your computer and use it in GitHub Desktop.
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
| class LegislatorsController < ApplicationController | |
| def search | |
| respond_to do |format| | |
| if cookies["zip"].to_s.blank? | |
| format.html # search.html.erb | |
| else | |
| format.html { redirect_to legislators_url } | |
| end | |
| end | |
| end | |
| def index | |
| if cookies["zip"].to_s.blank? | |
| location = Geocoding::get(params[:address]).first | |
| cookies["zip"] = location.postal_code | |
| cookies["lat"] = location.latitude.to_s | |
| cookies["long"] = location.longitude.to_s | |
| @results = Legislator.all_for(:latitude => location.latitude, :longitude => location.longitude) | |
| else | |
| @results = Legislator.all_for(:latitude => cookies[:lat], :longitude => cookies[:long]) | |
| end | |
| respond_to do |format| | |
| format.html | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment