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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:12:00+00:00 2026-06-14T09:12:00+00:00

What is the best way to handle a static data set (non-dynamic)? For instance,

  • 0

What is the best way to handle a static data set (non-dynamic)?

For instance, let’s say you have a model that has a set of 10 different instances, each of which is unique, but none of which will ever change throughout the lifetime of your application. It seems overkill to create an activerecord model and store this data in the database, but it seems ugly to create a generic class and store this data in the code.

What is accepted as a best practice?


Example:

You have a Rate and a User. A User can have a level from 1-10, when the level changes, the rate changes. The rate might have other information, so simply storing it as an attribute on the User might be more trouble than it’s worth. Would it make sense to tie it to a Rate or to create it as a method on the User like this:

def rate
  case self.level
  when 1:
    { value: "foo", something: "bar", else: "baz" }
  when 2:
    # etc
  end
end

It seems that neither of the solutions are ideal, but I’m not sure if there is something else ideal that could happen.

  • 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-06-14T09:12:02+00:00Added an answer on June 14, 2026 at 9:12 am

    I would store this information in a YAML file. You could use the RailsConfig gem and create a YAML file like

    level:
      1:
        some: value
        another: value
      2:
        some: second value
        another: second value
    

    And then access it with

    rate = 2
    val = Settings.level[rate.to_s].some
    

    (I’m not completely sure with numbers as keys in YAML, maybe you have to escape them)

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

Sidebar

Related Questions

I would like an opinion on what is the best way to handle static
What is the best way to handle unexisting actions in the Zend Framework? Depending
What's the best way to handle an expired password in an ASP.NET MVC application?
What is the best way to handle multiple Flex/Bison parsers inside a project? I
What is the best way to handle mysql database users connection in PHP? I
What's the best way to handle memory management with nested factory methods, such as
What is the best way to handle following situation? A dropdown(for master table) is
What is the best way to handle browser-specific CSS file loading? Assume you are
What is the best way to handle different subtypes of an abstract supertype as
What would be the best way to handle lightweight crash recovery for my program?

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.