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
class AppSettings < ActiveRecord::Base
before_create do
self.errors.add(:base, "already one setting object existing") and return false if AppSettings.exists?
end
def self.instance
AppSettings.first_or_create!(...)
end
end