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.


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

Now update your database with:

rake db:migrate


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 }

Using global settings:

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

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

Using settings fot some model:

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

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

Include Settingsable concern:

class User
  include Groupped::Settings::Settingsable

s = User.first.settings_group(:general, GeneralSettings)