File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change 5252Every setting is handled by the class ` RailsSettings::SettingObject ` . You can use your own class, e.g. for validations:
5353
5454``` ruby
55- class Project < ActiveRecord ::Base
56- has_settings :info , :class_name => ' ProjectSettingObject'
57- end
58-
5955class ProjectSettingObject < RailsSettings ::SettingObject
6056 validate do
6157 unless self .owner_name.present? && self .owner_name.is_a?(String )
@@ -65,6 +61,25 @@ class ProjectSettingObject < RailsSettings::SettingObject
6561end
6662```
6763
64+ Then you can use it like this:
65+
66+ ``` ruby
67+ class Project < ActiveRecord ::Base
68+ has_settings :info , :class_name => ' ProjectSettingObject'
69+ end
70+ ```
71+
72+ Or use it only on some of the settings:
73+
74+ ``` ruby
75+ class Project < ActiveRecord ::Base
76+ has_settings do |s |
77+ s.key :calendar # Will use the default RailsSettings::SettingObject
78+ s.key :info , :class_name => ' ProjectSettingObject'
79+ end
80+ end
81+ ```
82+
6883### Set settings
6984
7085``` ruby
You can’t perform that action at this time.
0 commit comments