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'
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
Dependencies
- Schema Validations (schema_validations)—unless you choose to implement the functionality yourself.
Installation
EDGE
To install using SVN:ruby script/plugin install svn://rubyforge.org/var/svn/redhillonrails/trunk/vendor/plugins/system_settings
or using HTTP:
ruby script/plugin install http://redhillonrails.rubyforge.org/svn/trunk/vendor/plugins/system_settings
2.0 Stable
To install using SVN:ruby script/plugin install svn://rubyforge.org/var/svn/redhillonrails/branches/stable-2.0/vendor/plugins/system_settings
or using HTTP:
ruby script/plugin install http://redhillonrails.rubyforge.org/svn/branches/stable-2.0/vendor/plugins/system_settings
1.2 Stable
To install using SVN:ruby script/plugin install svn://rubyforge.org/var/svn/redhillonrails/branches/stable-1.2/vendor/plugins/system_settings
or using HTTP:
ruby script/plugin install http://redhillonrails.rubyforge.org/svn/branches/stable-1.2/vendor/plugins/system_settings
1.1.6 Release
To install using SVN:ruby script/plugin install svn://rubyforge.org/var/svn/redhillonrails/tags/release-1.1.6/vendor/plugins/system_settings
or using HTTP:
ruby script/plugin install http://redhillonrails.rubyforge.org/svn/tags/release-1.1.6/vendor/plugins/system_settings
