Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. def index
  2. @search = Search.new
  3.  
  4. if location = Location.find_by_zip_code(params[:search])
  5. latitude = location.latitude * Math::PI / 180
  6. longitude = location.longitude * Math::PI / 180
  7.  
  8. locations = Location.search(
  9. :geo => [latitude, longitude],
  10. :with => {:geodist => 0.0..100_000.0},
  11. :order => 'geodist ASC',
  12. :per_page => 5_000
  13. )
  14. @users = User.where(zip_code: locations.map(&:zip_code))
  15.  
  16. else
  17. @users = User.search(params[:query],
  18. :conditions => { :ethnicity => params[:ethnicity], :religion => params[:religion], :children => params[:children], :gender => params[:gender], :age => params[:age] },
  19. :with => { :age => 18..65 },
  20. :geo => [current_user.latitude * Math::PI / 180.0, current_user.longitude * Math::PI / 180.0],
  21. :with => {:geodist => 0.0..100_000.0},
  22. :order => 'geodist ASC', :without => {:user_id => current_user.id})
  23.  
  24.  
  25.  
  26. end
  27. render 'users/index', layout: 'new_application'
  28.  
  29. end
  30.  
  31. @users = User.search(params[:search].gsub(/s+/, ' | '),
  32. :geo => [current_user.latitude * Math::PI / 180.0, current_user.longitude * Math::PI / 180.0],
  33. :with => {:geodist => 0.0..100_000.0},
  34. :order => 'geodist ASC', :without => {:user_id => current_user.id})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement