Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def index
- @search = Search.new
- if location = Location.find_by_zip_code(params[:search])
- latitude = location.latitude * Math::PI / 180
- longitude = location.longitude * Math::PI / 180
- locations = Location.search(
- :geo => [latitude, longitude],
- :with => {:geodist => 0.0..100_000.0},
- :order => 'geodist ASC',
- :per_page => 5_000
- )
- @users = User.where(zip_code: locations.map(&:zip_code))
- else
- @users = User.search(params[:query],
- :conditions => { :ethnicity => params[:ethnicity], :religion => params[:religion], :children => params[:children], :gender => params[:gender], :age => params[:age] },
- :with => { :age => 18..65 },
- :geo => [current_user.latitude * Math::PI / 180.0, current_user.longitude * Math::PI / 180.0],
- :with => {:geodist => 0.0..100_000.0},
- :order => 'geodist ASC', :without => {:user_id => current_user.id})
- end
- render 'users/index', layout: 'new_application'
- end
- @users = User.search(params[:search].gsub(/s+/, ' | '),
- :geo => [current_user.latitude * Math::PI / 180.0, current_user.longitude * Math::PI / 180.0],
- :with => {:geodist => 0.0..100_000.0},
- :order => 'geodist ASC', :without => {:user_id => current_user.id})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement