# This is a generic key/value store model class AppSetting < MongoRecord::Base collection_name :app_settings #get or set a variable with the variable as the called method def self.method_missing(method, *args) method_name = method.to_s super(method, *args) rescue NoMethodError setting = self.first || self.new #set a value for a variable if method_name =~ /=$/ var_name = method_name.gsub('=', '') value = args.first setting[var_name] = value setting.save #retrieve a value else setting[method_name] end end end