Skip to content

Store and retrieve Ruby on Rails application configuration settings in the database

License

Notifications You must be signed in to change notification settings

veridit/system_settings

Repository files navigation

System Settings

System Settings is a plugin that provides a convenient way to store and retrieve system configuration settings in the database. The plugin provides a single model SystemSetting with two properties name+, and value+ Names must be unique whereas values have no such restriction.

To create and retrieve system settings, the usual active record operations can be used:

SystemSetting.create(:name => "environment", :value => "production")
SystemSetting.find_by_name("environment")   # => "production"
SystemSetting[:environment]                 # => "production"

Note that you can lookup a system setting using either a string or a symbol.

Installation

You have two choices for installation. The first uses a gem (recommended):

config.gem "harukizaemon-system_settings", :lib => "system_settings", :source => "http://gems.github.com"

Or you can use the Rails plugin

$ ruby script/plugin install git://github.com/harukizaemon/system_settings.git

Once installed, System Settings requires the creation of a single table. You may choose to perform this step manually, or use the generator provided. To use the generator, run:

./script/generate system_settings_migration

This will generate an appropriately numbered migration script named NNN_create_system_settings.rb in the db/migrate directory. The next time you run rake migrate, the table will automatically be created for you.

If you would prefer a different name for the script, simply pass the name as an argument. For example:

./script/generate system_settings_migration create_the_system_settings_table

The plugin fully supports and understands the following active-record configuration properties:

  • config.active_record.pluralize_table_names

  • config.active_record.table_name_prefix

  • config.active_record.table_name_suffix

License

This plugin is copyright 2009 by Simon Harris and is released under the MIT license.

About

Store and retrieve Ruby on Rails application configuration settings in the database

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published