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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:59:20+00:00 2026-05-18T03:59:20+00:00

Apologies if the question is a little imprecise, but I’ll describe my problem below.

  • 0

Apologies if the question is a little imprecise, but I’ll describe my problem below.

I’m setting up some models in a Rails project, and one thing I’ve noticed I’m running into more than a few times is dealing with attributes that meet the following criteria:

  • They can be set to one of a small, predefined set of values
  • Those values need to have both a name and an identifier (whether a numeric id, code, whatever)
  • The values would only ever change as the result of a good deal of code change.

For example, one of my models should have a status field that can be set to one of: Defining, Executed, or Completed. I need to show those specific words within the interface, but I don’t want to store the strings in the DB in case I need to change them in the future (or internationalize, or whatever.)

The obvious option is to define models for each of these models, but that seems to present a good deal of overhead in maintaining the models, ensuring that I write migrations between environments, etc. for each one of these, which seems like a lot of overhead.

The other option is to store it as an integer, and whip up an “enumeration” type class that stores the translation of those values – this would probably work fine, but I’m concerned that I’ll lose associations and other handy stuff I get from ActiveRecord models.

Any advice on the best way to handle this situation?

  • 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-18T03:59:20+00:00Added an answer on May 18, 2026 at 3:59 am

    Check out the ruby gem I’ve been working on called classy_enum. I’m pretty sure it does exactly what you’re looking for. The README has some example usage, but the premise is that it lets you define multiple enum members as classes that can have different properties.

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

Sidebar

Related Questions

Apologies in advance for the long-winded question. I'm really a database programmer, but have
Apologies if I missed this question already, but I searched and couldn't find it.
Apologies for reposting but I had to edit this question when I got to
My apologies, I've actually asked this question multiple times, but never quite understood the
Apologies if this question is a bit daft, but are there any negative repercussions
First off, apologies if this question has been asked before but I couldn't find
Apologies if this ends up being a stupid question, but I was just wondering
This is a rather elementary C# question; my apologies, but I haven't been able
Final question for the night. And apologies for the complete noobness of this. I
Good morning, Apologies for the newbie question. I'm just getting started with ASP.NET internationalization

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.