Skip to content

Instantly share code, notes, and snippets.

@mileszs
Created March 27, 2009 19:32
Show Gist options
  • Select an option

  • Save mileszs/86843 to your computer and use it in GitHub Desktop.

Select an option

Save mileszs/86843 to your computer and use it in GitHub Desktop.
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