Permalink
Browse files

Updating action to send lat and lon to Sphinx

  • Loading branch information...
1 parent 0d9d404 commit c469983fb80b4e2676e398eea5c16b83c299b18b @pat pat committed Sep 29, 2008
Showing with 11 additions and 1 deletion.
  1. +11 −1 app/controllers/contacts_controller.rb
@@ -8,7 +8,11 @@ def index
(params[:search] || ""),
:with => {:state_id => params[:state_id].to_i},
:page => (params[:page] || 1),
- :order => :name
+ :geo => [
+ degrees_to_radians(params[:lat].to_f),
+ degrees_to_radians(params[:lon].to_f)
+ ],
+ :order => "@geodist ASC"
)
respond_to do |format|
@@ -89,4 +93,10 @@ def destroy
format.xml { head :ok }
end
end
+
+ private
+
+ def degrees_to_radians(degree)
+ degree * Math::PI / 180
+ end
end

0 comments on commit c469983

Please sign in to comment.