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 6695793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:15:53+00:00 2026-05-26T06:15:53+00:00

First, sorry for bad title, couldn’t come up with something more descriptive. I have

  • 0

First, sorry for bad title, couldn’t come up with something more descriptive.

I have a user model. I’d like to set a type for that user which can be one of 5 options; doesn’t matter what the options are, any strings will do. I’d like to be able to search based on these options.

I think I have the following options:

  1. Added field as string to model with index
  2. Create a user_type table and do belongs_to/has_many relationship
  3. Save type as integer and map integer to a constant defined in user model, with string value (no idea how to do this though)

What’s the Rails Way to solve this problem that will meet the following goals:

  • Searchable
  • Maintainable
  • Readable

Thank you

  • 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-26T06:15:53+00:00Added an answer on May 26, 2026 at 6:15 am

    This really does depend on your meaning of ‘type’. If it’s a role (such as “administrator”, “moderator”, “user”, etc.) where a given user can only be of one type, you can just do it with a string column – no need for a separate table.

    If the user can be multiple types simultaneously (“newly-registered”, “male”, “student”, “blogger”), where the user type works more like a tag, then your user_type table will do the job.

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

Sidebar

Related Questions

At first sorry for my really bad title! If you have a better title
First, sorry for my bad english. I have an EF entity that looks like:
first of all: sorry for bad title, didn't knew how to tell my problem
First thanks for reading me and sorry for my bad english. I have the
First of all, sorry for my bad English... I have a problem with one
First, sorry for my bad English. I'm trying to get an IP from user.
First sorry for my bad English. I have this menubar in PHP. I want
first, sorry for the bad english. I have a test that submit a login
First of all, sorry about that title. I'm not the best at writing those
Sorry, this's my first time to ask a question here. So, I don't have

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.