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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:16:50+00:00 2026-05-25T03:16:50+00:00

Background I’m writing a photo gallery, the gallery can create both previews and thumbnails.

  • 0

Background

I’m writing a photo gallery, the gallery can create both previews and thumbnails.

I want the user to customize the creation of these (resolution etc)

What I have so far

  • config/gallery.yml – Stores the actual settings, a block for each env
  • config/initializers/gallery.rb – Loads the YAML file into Gallery::Application
  • app/models/image.rb – The model that reads the configuration and creates the images

My question

Where is the best place to merge the settings with the default values?
I could either do it in gallery.rb or image.rb where it’s actually used.

Otherwise, is this a sane approach or have I gone about this all wrong?
Any feedback is greatly appreciated.

Files

config/initializers/gallery.yml

production:
  create_previews: true
  create_thumbnails: true

development:
  create_thumbnails: true
  create_previews: true

test:
  create_thumbnails: false
  create_previews: false

config/initializers/gallery.rb

Gallery::Application.config.image_directory = File.join(Rails.root, 'images')
Gallery::Application.config.thumbnail_directory = File.join(Rails.root, 'thumbnails')
Gallery::Application.config.preview_directory = File.join(Rails.root, 'previews')

# DO NOT MODIFY THE LINES BELOW

EXTERNAL_CONFIG_FILE_PATH = "#{Rails.root}/config/gallery.yml"

if FileTest.exists? EXTERNAL_CONFIG_FILE_PATH
  vals = YAML.load_file(EXTERNAL_CONFIG_FILE_PATH)[::Rails.env]
else
  vals = {}
end

Gallery::Application.config.create_previews = vals['create_previews']
Gallery::Application.config.preview_settings = vals['preview_settings']

Gallery::Application.config.create_thumbnails = vals['create_thumbnails']
Gallery::Application.config.thumbnail_settings = vals['thumbnail_settings']
  • 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-25T03:16:50+00:00Added an answer on May 25, 2026 at 3:16 am

    I also agree this is good place in config/initializers.
    but other place and way is read/write database table field in GalleryConfig ActiveRecord model using MySQL.
    because easy for testcase or rails console.

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

Sidebar

Related Questions

Background, Part 1 I have a form that collects both frequency and duration from
Background: I'm writing a 'standard' (nothing special) web application in Ruby (not Rails) and
Background I am writing code in VS 2010, .NET 4, C#. Also, in case
Background - I want to extract specific columns from a csv file. The csv
Background I am writing and using a very simple CGI-based (Perl) content management tool
Background I am trying to create a copy of a business object I have
Background I have been asked by a client to create a picture of the
Background: I am writing a flash game and have encountered a problem. I have
Background: I want to check-out the source code from Cliche , which is stored
Background I have a pair of functions I want to use to animate some

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.