Created
June 23, 2009 16:13
-
-
Save rgraff/134641 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
# In application_controller | |
def current_postal | |
@postal_code ||= PostalCode.find_first_valid_in_united_states( | |
[params[:postal_code], previous_postal_requests.last, postal_from_geoip, 90013], | |
:include=>:territory) | |
end | |
# In postal_code.rb | |
def self.find_first_valid(zip_codes_to_try, options = {}) | |
zip_codes_to_try.each do |zip| | |
found = PostalCode.find_by_postal_code_and_country_name(zip,'United States', options) | |
return found if found | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment