# A model for Ruby on Rails that gets settings from a DB # And it caches them! Success! class Preference < ActiveRecord::Base def self.get(name) return Rails.cache.fetch(name) { output = self.find_by_name!(name) Rails.cache.write(name,output.value) } end end