Skip to content

Commit

Permalink
Updates the README page to document this update
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesús Burgos committed Jul 27, 2018
1 parent 7982297 commit c406ad8
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ end
Every setting is handled by the class `RailsSettings::SettingObject`. You can use your own class, e.g. for validations:

```ruby
class Project < ActiveRecord::Base
has_settings :info, :class_name => 'ProjectSettingObject'
end

class ProjectSettingObject < RailsSettings::SettingObject
validate do
unless self.owner_name.present? && self.owner_name.is_a?(String)
Expand All @@ -65,6 +61,25 @@ class ProjectSettingObject < RailsSettings::SettingObject
end
```

Then you can use it like this:

```ruby
class Project < ActiveRecord::Base
has_settings :info, :class_name => 'ProjectSettingObject'
end
```

Or use it only on some of the settings:

```ruby
class Project < ActiveRecord::Base
has_settings do |s|
s.key :calendar # Will use the default RailsSettings::SettingObject
s.key :info, :class_name => 'ProjectSettingObject'
end
end
```

### Set settings

```ruby
Expand Down

0 comments on commit c406ad8

Please sign in to comment.