Low commit activity in last 3 years
A long-lived project that still receives updates
Groupped::Settings is a plugin that manage groupped settings for Rails :)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Yet another 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)