Defect #7104

Accessing core Setting.* values in a plugin's init causes the plugin's settings to not load

Added by Robert Chady about 7 years ago. Updated almost 7 years ago.

Status:NewStart date:2010-12-13
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Plugin API
Target version:-
Resolution: Affected version:

Description

If you access a core value from Setting, such as host_name from a plugin's init.rb, then the plugin's settings will not be properly loaded.

To reproduce, create a simple plugin that does something like:

myurl = Setting.host_name

and then add in some settings

settings :default => {
'myvar' => 'myval'
}, :partial => 'settings/mysettings'

And then try to access the configure page from Administration / Plugins. You can also go in to the console and try to access Setting.plugin_#{your_plugin_name} here -- you will see it is not available. Meanwhile, all aspects of your plugin work fine, other than the settings and anything that tries to reference the settings.

History

#1 Updated by Jean-Baptiste Barth almost 7 years ago

  • Assignee deleted (Jean-Philippe Lang)
  • Priority changed from High to Normal

Somehow discussed in the forum: http://www.redmine.org/boards/3/topics/16587. I ended up not accessing Setting directly in my init.rb (commit)

I admit it's annoying but don't think it's "high" priority since core functionalities are not concerned.

Plus accessing "Setting" values in init.rb may not be a good idea if you want to put your plugin in a fresh redmine install (db:migrate would fail as the table is empty IIRC).

Also available in: Atom PDF