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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:33:36+00:00 2026-05-10T23:33:36+00:00

I have a site in rails and want to have site-wide settings. One part

  • 0

I have a site in rails and want to have site-wide settings. One part of my app can notify the admin by SMS if a specific event happens. This is an example of a feature that I want configurable via the site-wide settings.

So I was thinking I should have a Setting model or something. It needs to be a model because I want to be able to has_many :contacts for the SMS notification.

The problem is that there can only be one post in the database for the settings model. So I was thinking of using a Singleton model but that only prevents new object to be created right?

Would I still need to create getter and setter methods for each attribute like so:

def self.attribute=(param)   Model.first.attribute = param end  def self.attribute   Model.first.attribute end 

Is it perhaps not best-practice to use Model.attribute directly but always create an instance of it and use that?

What should I do here?

  • 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. 2026-05-10T23:33:37+00:00Added an answer on May 10, 2026 at 11:33 pm

    I am not sure I’d waste the database/ActiveRecord/Model overhead for such a basic need. This data is relatively static (I am assuming) and on the fly calculations aren’t necessary (including database lookups).

    Having said that, I’d recommend you define a YAML file with your site-wide settings and define an initializer file that loads the settings into a constant. You won’t have nearly as many of the unnecessary moving parts.

    There is no reason that data couldn’t just sit in memory and save you a ton of complexity. Constants are available everywhere, and they don’t need to be initialized or instantiated. If its absolutely critical that you utilize a class as a singleton, I’d recommend doing these two things:

    1. undef the initialize/new method
    2. define only self.* methods that way it is not possible for you to maintain a state
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 66k
  • Answers 66k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer but try doing this: Go the central administration operations service… May 11, 2026 at 11:31 am
  • added an answer There is several ways to approach this issue. But let… May 11, 2026 at 11:31 am
  • added an answer Use :order => 'criteria' for anything simple that can be… May 11, 2026 at 11:31 am

Related Questions

I have a site in rails and want to have site-wide settings. One part
I have a Rails site, where the content is written in markdown. I wish
I have a site running in a Windows shared hosting environment. In their control
I have a site developed in ASP.NET and hosted on a windows server using
I have a web site in asp.net that uses a master page. In this
I have written a site in Prototype but want to switch to jQuery. Any
I have a site with multiple document libraries in it. One of the site
I have a site with the following robots.txt in the root: User-agent: * Disabled:
I have a site that I am currently working on in ASP.NET 2.0 using
I have a site where users can post stuff (as in forums, comments, etc)

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.