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

  • Home
  • SEARCH
  • 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 7194875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:27:50+00:00 2026-05-28T20:27:50+00:00

What I’m trying to do: I’m trying to find out if there is a

  • 0

What I’m trying to do:

I’m trying to find out if there is a quick way to get country_select to store integers representing the countries instead of storing the country names/strings themselves. I’m using the country select gem.

Possible solution:

One way I’m thinking this can be done is if I install the gem as a plugin and edit the countries array to have arrays within the main array with integers and a string e.g. COUNTRIES = [[“United Kingdom”, 1],[“United States”, 2]]

This way in my form there will be values representing the strings. Then I can have a country_id column in my profiles table where users selected countries id will be stored. I will have a separate table “countries” that will have the countries stored in it and I’ll use the country_id of the profiles table to reference the correct country in the countries table.

Doing it this way would mean I would still get the good features of the gem/plugin such as having priority countries at the top of the select list. Something I don’t know how to do on my own.

It would take long but it could work. If I chose this solution where would I put the plugin? vendors folder in my apps directory right?

But if there is a quicker way to do this I’d like to do it that way.

A bigger picture:

Ok I have a search form where a user can browse the sites users filtering out results by:

text typed location
gender
sexuality
marital status
country

I’m using thinking sphinx and when filtering attributes it seems that the attributes need to be represented integers because everything works but the country.

I’m using the country select gem and it seems to only store strings and not an integer representing the string.

I would like to have it store integers instead.

Here are some contants I use in my search forms:

module ApplicationHelper

    GENDER            = [["Select", nil],["Male", 1],["Female", 2]]

    ETHNICITY         = [["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 ]]

    MARITAL_STATUS    = [[' Select', nil],['Single', 1 ],['Dating', 2 ],['In relationship', 3 ],['Married', 4 ],
                         ['Living Together', 5 ],['Divorced', 6 ],['Separated', 7 ],['Widowed', 8 ]]

    SEXUAL_PREFERENCE = [[' Select', nil],['Straight', 1 ],['Gay', 2 ],['Bi-sexual', 3 ]]

end

The search/browse form:

<%= form_tag browsers_path, :method => 'get' do %>
  <p>
    Location: <%= text_field_tag :location, params[:location] %>
<br />
    Country: <%= country_select :country, [ "United Kingdom", "France", "Germany" ] %>
<br />
    Gender: <%= select_tag :gender, options_for_select(ApplicationHelper::GENDER, params[:gender]) %>
<br />
    Ethnicity: <%= select_tag :ethnicity, options_for_select(ApplicationHelper::ETHNICITY, params[:ethnicity]) %>
<br />

    Marital status: <%= select_tag :marital_status, options_for_select(ApplicationHelper::MARITAL_STATUS, params[:marital_status]) %>
<br />
    Sexual preference: <%= select_tag :sexual_preference, options_for_select(ApplicationHelper::SEXUAL_PREFERENCE, params[:sexual_preference]) %>
<br />
    <%= submit_tag "Search", :name => nil %>
  </p>
  <% end %>

as you can see each array has a string and an integer. If you check out the array from the country_select gem there are just strings.

I’d appreciate an explanation of the best possible way to do what I’m trying to do and a clear example if possible.

I hope this post made sense.

Kind regards

  • 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-28T20:27:51+00:00Added an answer on May 28, 2026 at 8:27 pm

    I ended up recreating the country list from wikipedia with name of country and iso code as value. Much more straight forward and I got to store countries as their iso code and as integers making it possible to use the attribute with thinking sphinx.

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I know there's a lot of other questions out there that deal with this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group

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.