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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:36:51+00:00 2026-05-31T17:36:51+00:00

I have a couple large arrays that need to be available to a specific

  • 0

I have a couple large arrays that need to be available to a specific view. Currently I’m storing these in YAML files and loading into controller constants, as below.

I assume that this constant is stored in memory when Rails loads the file during environment setup, but the paranoid part of me wonders if I’m hitting the filesystem each time that controller is accessed. Can anyone suggest best practices in this area?

class OnboardingController < ApplicationController

  BRANDS = YAML.load(File.open("#{Rails.root}/config/brands.yml", 'r'))
  STORES = YAML.load(File.open("#{Rails.root}/config/stores.yml", 'r'))

  # ...
  • 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-31T17:36:53+00:00Added an answer on May 31, 2026 at 5:36 pm

    I assume that this constant is stored in memory when Rails loads
    the file during environment setup

    Yep, when the file is loaded/required, everything in there is executed
    and assigned. Therefore it’s loaded only once.

    but the paranoid part of me wonders if I’m hitting the filesystem
    each time that controller is accessed.

    Partially true, in development mode, constants are unset with each
    request, but that shouldn’t matter in production.

    Can anyone suggest best practices in this area?

    Leave it as it is, caching only forwards the parsing to the first request
    instead of at startup where you’ve got the time because the old worker
    is still running.

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

Sidebar

Related Questions

I have a couple of large json files that I need to check for
I have couple of dozen pieces of data that I need to save and
I have couple resource DLLs that I currently load when application starts using following
I have a couple large tables (188m and 144m rows) I need to populate
I have a couple of binary files that are used in image processing where
I have a couple of very large tables (over 400,000 rows) that look like
I have a fairly large 3DS scene with many individual meshes - a couple
We have couple different web-apps that share the same db link. The hibernate layer
I have written a java program that tests the speed of a couple of
I have a couple of HP M5 servers that I've been collecting temperature reference

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.