Skip to content

Commit c406ad8

Browse files
author
Jesús Burgos
committed
Updates the README page to document this update
1 parent 7982297 commit c406ad8

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ end
5252
Every 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-
5955
class 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
6561
end
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

0 commit comments

Comments
 (0)