Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7180787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:25:19+00:00 2026-05-28T17:25:19+00:00

Am I doing something wrong? If I don’t have the with options added location

  • 0

Am I doing something wrong?

  1. If I don’t have the with options added location works and I get results shown as soon as I enter the browser page of my website.

  2. When i hit the page all users are shown by 20 per page. If I add with_all gender => params[:gender], location still works and I type in a location and filter results by gender and results are successfully returned.

  3. If I add ethnicity to the with_all hash then ethnicity works and results are turned but gender and location no longer work.

It’s like it only allows 1 attribute for filtering.

I have rebuilt the index several times so I don’t get what’s going on.

I’ve got text search for location and 2 filters set 1. gender, 2. ethnicity

Here is my Profile model for the profiles table that stores all the attributes above:

  define_index do

    indexes location
        has ethnicity, :type => :integer
        has gender, :type => :integer

  end

Here is my controller:

 class BrowsersController < ApplicationController
  def index
    @default_image = "/assets/default_avatar.jpg"
    #gender = params[:gender].to_i
    @users = Profile.search params[:location], 
                                   :page => params[:page], 
                                   :per_page => 20,
                                   :with_all => 
                                                { 
                                   :gender => params[:gender], 
                                   :ethnicity => params[:ethnicity] 
                                                }

  end
end

my view form:

<%= form_tag browsers_path, :method => 'get' do %>
  <p>
    Location: <%= text_field_tag :location, params[:location] %><br />
    Gender: <%= select_tag :gender, 
               options_for_select([["Select", nil], 
                  ["Male", 1], 
                 ["Female", 2]], params[:gender]) %>
<br />
    Ethnicity: <%= select_tag :ethnicity, 
               options_for_select([["Select", nil],['Black', 1 ],['White / Caucasian', 2 ],['European', 3 ],['Asian', 4 ],['Indian', 5 ],['Middle Eastern', 6 ],['Native American', 7 ],['Hispanic', 8 ],['Mixed Race', 9 ],['Other Ethnicity', 10 ]], params[:ethnicity]) %>
<br />
    <%= submit_tag "Search", :name => nil %>
  </p>
  <% end %>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:25:20+00:00Added an answer on May 28, 2026 at 5:25 pm

    There’s a lot to digest in your question, but here’s a few things to note – perhaps they will help:

    :with_all is for matching multiple values in a single multi-value attribute – for example, matching an article that has all three tag ids would use this: :with_all => {:tag_ids => [1, 2, 3]}.

    :with, however, is perfectly fine for having filters on more than one attribute – which is what you seem to be after (although :with_all with single filter values behaves in just the same way).

    Sphinx treats nils/NULLs as 0’s – so, if you’re filtering by a gender but not an ethnicity, then what your controller code is doing is searching for profiles with the given gender and an ethnicity of 0. Perhaps try something like this instead:

    filters = {}
    filters[:gender]    = params[:gender].to_i    if params[:gender].present?
    filters[:ethnicity] = params[:ethnicity].to_i if params[:ethnicity].present?
    
    @users = Profile.search params[:location], 
      :page     => params[:page], 
      :per_page => 20,
      :with     => filters
    

    Finally – the gender and ethnicity columns are integers, yes? If so, you don’t need to specify :type => :integer in your index definition – that’ll be done automatically.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So obviously I am doing something wrong, but I just cannot seem to get
Maybe I'm doing something wrong but I have a textarea where I've specified textAlign
I've read several docs and I don't get it: I know I'm doing something
I don't know if I'm doing something wrong or right, but when I'm debugging
I don't know if I am doing something wrong I think I am or
I know I'm doing something wrong here, I just don't know what as I'm
Am I doing something wrong? It looks like this only works in IE, though
I don't know if I'm doing something wrong, but I'm 100% sure it's the
Am I doing something wrong or is it not possible to specify a generic
I must be doing something wrong. I can't seem to execute my CustomValidator's ServerValidate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.