Accessing our settings
Redmine's Setting
model can be used to retrieve the settings values that we've configured.
The Setting
model is used internally by Redmine to manage all internal settings. Since the actual values that are being stored are YAML-encoded, they can be more complex than simple strings or integers. The structure of a Setting
entry is as follows:
Setting(id: integer, name: string, value: text, updated_on: datetime)
When accessing a plugin settings value, we need to provide the internal name of the setting as well as the key of the specific settings value we want to retrieve. This request takes the following form:
Setting['plugin_redmine_knowledgebase'][key]
The naming convention used is plugin_#{plugin.id}
as this is how Redmine internally manages plugin settings (for more information, see /path/to/redmine/app/models/setting.rb
).
In the previous section, we discussed the disabling of article summaries if the administrator sets the appropriate toggle in our plugin's configuration...