Skip to content
[MIRROR] Groupped::Settings is a plugin that manage groupped settings for Rails :)
Ruby Dockerfile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
spec
.gitignore
.gitlab-ci.yml
.rspec
.rubocop.yml
AUTHORS
Dockerfile
Gemfile
Gemfile.lock
LICENSE
README.md
Rakefile
docker-compose.yml
groupped_settings.gemspec

README.md

Yet anoter Settings Plugin for Rails

Gem Version Gem YARD

Coverage Quality Outdated Vulnerabilities

Groupped::Settings is a plugin that manage groupped settings for Rails :) Settings stored in own database table as json(b) field. Splitted by groups and can have polymorphyc referece to other models.

Setup

rails g rake groupped_settings:install rails g rake groupped:settings:migration

Now update your database with:

rake db:migrate

Usage

Define settings group class.

class GeneralSettings < Groupped::Settings::Group
  self.group_name = 'general'

  attribute :identifier, :string, default: 'application'
  attribute :secret, :string

  validates :identifier, presence: true
  validates :secret, length: { minimum: 16 }
end

Using global settings:

s = GeneralSettings.load
s.identifier = '123123123'
s.save!

s = Groupped::Settings[:general, GeneralSettings]
s.secret = '12345678987654321'
s.save!

Using settings fot some model:

s = GeneralSettings.load(target: User.first)
s.identifier = '123123123'
s.save!

s = Groupped::Settings[:general, User.first]
s.secret = '12345678987654321'
s.save!

Include Settingsable concern:

class User
  include Groupped::Settings::Settingsable
end


s = User.first.settings_group(:general, GeneralSettings)
You can’t perform that action at this time.