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 52
52
Every setting is handled by the class ` RailsSettings::SettingObject ` . You can use your own class, e.g. for validations:
53
53
54
54
``` ruby
55
- class Project < ActiveRecord ::Base
56
- has_settings :info , :class_name => ' ProjectSettingObject'
57
- end
58
-
59
55
class ProjectSettingObject < RailsSettings ::SettingObject
60
56
validate do
61
57
unless self .owner_name.present? && self .owner_name.is_a?(String )
@@ -65,6 +61,25 @@ class ProjectSettingObject < RailsSettings::SettingObject
65
61
end
66
62
```
67
63
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
+
68
83
### Set settings
69
84
70
85
``` ruby
You can’t perform that action at this time.
0 commit comments