was shooting for the smallest, most extensible preferences class i could get. email me any comments—i’d like opinions on this.
1 class Preference < ActiveRecord::Base
2 belongs_to :user
3
4 #FIXME descriptions should be in a config file?
5 COMMON_DEFAULTS = {
6 :email_on_message => [true,
7 "Email when you get a message?"],
8 :online_status_visible => [false,
9 "Status visible to everyone?"],
10 :public_profile => [false,
11 "Full profile visible to everyone?"]
12
13 }
14
15
16 class << self
17 def description_for(key)
18 (COMMON_DEFAULTS[key.to_sym] &&
19 COMMON_DEFAULTS[key.to_sym][1]) ||
20 nil
21 end
22 end
23
24 end
XML