Created
March 8, 2010 16:45
-
-
Save danhixon/325338 to your computer and use it in GitHub Desktop.
This file contains 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
# Building on the zips_near_zip procedure in this gist: http://gist.github.com/319908 | |
# I added a named scope to my model which has an attribute of "service_address_id": | |
# call to sanitize_sql_array to avoid sql injection. | |
named_scope :near_zip, lambda { |zip, miles| | |
{ :joins=>sanitize_sql_array(["join addresses | |
on service_address_id=addresses.id | |
join zips_near_zip(?,?) | |
on zip_code = zip",zip, miles]) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment