settings database table alongside Redmine’s own settings.
Declaring settings in init.rb
Call thesettings method inside your Redmine::Plugin.register block. It accepts two keys:
:default— a hash of default values applied when no setting has been saved yet.:partial— path to the settings form partial, relative to your plugin’sapp/views/directory.
Default values are used only when the setting has not yet been saved by an administrator. The
:partial path is relative to plugins/my_plugin/app/views/ — the example above maps to plugins/my_plugin/app/views/settings/_my_plugin_settings.html.erb.Creating the settings partial
Create the partial at the path declared in:partial. The plugin settings hash is available as the local variable settings.
Reading settings in your plugin
Access saved settings anywhere in your plugin (models, controllers, views, jobs) using:Setting.plugin_<plugin_id>. To read a single value:
Using settings in a controller
Using settings in a view
Where settings are stored
Redmine stores all plugin settings in thesettings table as a single serialized value per plugin. The row has:
name=plugin_<plugin_id>(e.g.,plugin_my_plugin)value= YAML-serialized hash of all setting key-value pairs
Settings page in the UI
Once you add thesettings declaration and create the partial, a Configure link appears next to your plugin on Administration > Plugins. Clicking it renders your partial inside Redmine’s standard settings form. Redmine handles saving and displaying flash messages.
The
configurable? method on Redmine::Plugin returns true only when both :default and :partial are present. If :partial is missing, no Configure link appears.