{"id":14956007,"url":"https://github.com/krists/system_settings","last_synced_at":"2025-09-14T08:33:32.153Z","repository":{"id":55393978,"uuid":"184410339","full_name":"krists/system_settings","owner":"krists","description":"System Settings is a Rails engine that adds settings functionality","archived":false,"fork":false,"pushed_at":"2023-04-11T13:43:37.000Z","size":568,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-31T03:31:25.257Z","etag":null,"topics":["engine","rails","ruby-on-rails","settings"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/krists.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-01T12:04:46.000Z","updated_at":"2024-07-29T23:03:52.000Z","dependencies_parsed_at":"2024-10-10T05:15:04.107Z","dependency_job_id":"0b004d2b-6bed-45a3-bcc2-a0218e6cb111","html_url":"https://github.com/krists/system_settings","commit_stats":{"total_commits":98,"total_committers":3,"mean_commits":"32.666666666666664","dds":0.3877551020408163,"last_synced_commit":"8c298473400f64832245ddc493b58a2ba219d262"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krists%2Fsystem_settings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krists%2Fsystem_settings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krists%2Fsystem_settings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krists%2Fsystem_settings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krists","download_url":"https://codeload.github.com/krists/system_settings/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232962563,"owners_count":18603379,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["engine","rails","ruby-on-rails","settings"],"created_at":"2024-09-24T13:12:10.264Z","updated_at":"2025-01-08T02:07:10.994Z","avatar_url":"https://github.com/krists.png","language":"Ruby","readme":"# System Settings\nSystem Settings is a Rails engine that adds settings functionality.\n\nInitial setting values can be loaded from file and later edited in a System Settings provided admin panel.\n\n\n## Getting started\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'system_settings'\n```\n\nAnd then execute:\n```bash\n$ bundle\n```\n\nCopy migrations:\n```bash\n$ bin/rails system_settings:install:migrations\n```\n\nAnd then run the migrations:\n```bash\n$ bin/rails db:migrate\n```\n\nCreate settings file where all settings will be defined:\n```bash\n$ touch config/system_settings.rb\n```\n\nAdd your first setting to `config/system_settings.rb`:\n```ruby\n# String type values\nstring :default_mail_from, value: \"Example Company \u003cnoreply@example.com\u003e\", description: \"This email will be used for all outgoing emails\"\nstring :date_format, value: \"%Y-%m-%d\"\nstring :default_locale, value: \"en\"\n\n# Integer type values\ninteger :default_records_per_page, value: 25\ninteger :remainder_interval_in_hours, value: 48\n\n# Decimal values\ndecimal :max_temp, value: 95.2\n\n# Array type strings, integers and decimals\nstring_list :admin_emails, description: \"Will receive alerts\"\nstring_list :upload_allowed_extensions, value: [\"docx\", \"pdf\", \"txt\"]\ninteger_list :lucky_numbers, description: \"Prime numbers are more effective\", value: [2, 3, 5, 11]\ndecimal_list :allowed_multipliers, value: [12.3, 99, BigDecimal(\"-87\")]\n```\n\nLoad values from `config/system_settings.rb` into database:\n```bash\n$ ./bin/rails system_settings:load\n```\n\nAdd System Settings admin panel to Rails routes:\n```ruby\nRails.application.routes.draw do\n  mount SystemSettings::Engine, at: \"/system_settings\"\n  # rest of your routes..\nend\n```\n\nFinal step. Access settings values anywhere in your code:\n```ruby\nSystemSettings[:date_format] # =\u003e \"%Y-%m-%d\"\nSystemSettings[:lucky_numbers] # =\u003e [2, 3, 5, 11]\n\n# You can change setting's value like any other Rails model.\nSystemSettings::Setting.find_by(name: \"default_mail_from\").update({value: \"No-Reply \u003cnoreply@example.com\u003e\"})\n```\n\n\n## Do not forget!\nBefore using System settings in production please protect the `/system_settings` endpoint with routing constraint. You can read more about it in [Rails Guides: Rails Routing from the Outside In](https://guides.rubyonrails.org/routing.html#advanced-constraints)\n\n```ruby\nRails.application.routes.draw do\n  mount SystemSettings::Engine, at: \"/system_settings\", constraints: AdminRoutingConstraint.new\n  # rest of your routes..\nend\n```\n\n\n## Few more things\n\nWhen you run `./bin/rails system_settings:load` task it will read `config/system_settings.rb` file and add new entries to the database. If you would like to replace all values with the ones from the file then run `./bin/rails system_settings:reset` \n\nSystem Settings admin panel is precompiled at gem's build time. So it does not require any Javascript runtime and can be used with api-only Rails applications.\n\nIf you would like to store your settings somewhere else than `config/system_settings.rb` you can use ENV variable `SYSTEM_SETTINGS_PATH` to specify custom path.\n\n\n## Using System Settings in tests\n\nYour test suite probably clears database before/after every test example. Fortunately is very easy to load fresh settings from configuration file.\nIt can be done by running `SystemSettings.load`. It will persist all loaded settings. But if you would like to persist only a subset of loaded settings run `SystemSettings.load(:one, :two, :three)`.\n\nAnd if you modify settings values in test example you can reset to defaults with `SystemSettings.reset_to_defaults`.\n\n\n## Development\n\nOptional development tools:\n* [direnv](https://direnv.net/) - Unclutter your .profile\n\nRequired environment variables:\n* `RAILS_VERSION`\n* `SQLITE3_VERSION`\n\nAs System Settings gem is being developed to be compatible with multiple [Rails](https://github.com/rails/rails) versions,\nyou need to set `RAILS_VERSION` and `SQLITE3_VERSION` environment variables when running `bundle install` or any `./bin/rails` command.\nIt is recommended to set these up using [direnv](https://direnv.net/) and `.envrc` file.\n\n\nGetting started with development:\n1) `RAILS_VERSION=5.2.3 SQLITE3_VERSION=1.4.1 bundle`\n2) `RAILS_VERSION=5.2.3 SQLITE3_VERSION=1.4.1 ./bin/rails db:create db:migrate`\n3) `RAILS_VERSION=5.2.3 SQLITE3_VERSION=1.4.1 ./bin/rails test`\n\n## Build status\nSystem Settings is being tested with Rails versions - `5.0`, `5.1`, `5.2`, `6.0`, `rails repo master branch`\n\n[![Build Status](https://dev.azure.com/kristsozols/System%20Settings/_apis/build/status/krists.system_settings?branchName=master)](https://dev.azure.com/kristsozols/System%20Settings/_build/latest?definitionId=1\u0026branchName=master)\n[![Maintainability](https://api.codeclimate.com/v1/badges/3ad889ca36f62bad04dc/maintainability)](https://codeclimate.com/github/krists/system_settings/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/3ad889ca36f62bad04dc/test_coverage)](https://codeclimate.com/github/krists/system_settings/test_coverage)\n\n## License\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrists%2Fsystem_settings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrists%2Fsystem_settings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrists%2Fsystem_settings/lists"}