1

Hy, everyone! I have an error in ruby code of my plugin for Redmine. Error occurs then method Setting.plugin_myplugin['myplugin_setting'] is called.

Here traceback of this error:

NoMethodError (undefined method `plugin_myplugin' for #<Class:0x00000004874098>):
  activerecord (3.2.17) lib/active_record/dynamic_matchers.rb:55:in `method_missing'
  plugins/myplugin/lib/myplugin/patches/account_controller_patch.rb:36:in `login_with_myplugin'
  actionpack (3.2.17) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (3.2.17) lib/abstract_controller/base.rb:167:in `process_action'
  actionpack (3.2.17) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (3.2.17) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
  activesupport (3.2.17) lib/active_support/callbacks.rb:447:in `_run__4412462782733274046__process_action__1678150651014813342__callbacks'
  activesupport (3.2.17) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.17) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
  activesupport (3.2.17) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.17) lib/abstract_controller/callbacks.rb:17:in `process_action'
  actionpack (3.2.17) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (3.2.17) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
  activesupport (3.2.17) lib/active_support/notifications.rb:123:in `block in instrument'
  activesupport (3.2.17) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (3.2.17) lib/active_support/notifications.rb:123:in `instrument'
  actionpack (3.2.17) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
  actionpack (3.2.17) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
  activerecord (3.2.17) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (3.2.17) lib/abstract_controller/base.rb:121:in `process'
  actionpack (3.2.17) lib/abstract_controller/rendering.rb:45:in `process'
  actionpack (3.2.17) lib/action_controller/metal.rb:203:in `dispatch'
  actionpack (3.2.17) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
  actionpack (3.2.17) lib/action_controller/metal.rb:246:in `block in action'
  actionpack (3.2.17) lib/action_dispatch/routing/route_set.rb:73:in `call'
  actionpack (3.2.17) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
  actionpack (3.2.17) lib/action_dispatch/routing/route_set.rb:36:in `call'
  journey (1.0.4) lib/journey/router.rb:68:in `block in call'
  journey (1.0.4) lib/journey/router.rb:56:in `each'
  journey (1.0.4) lib/journey/router.rb:56:in `call'

System specifications:

  • Redmine 2.5.1
  • apache2.2.22-1ubuntu1.5
  • Passenger 4.0.4
  • ruby 1.9.3p545

Does anyone know what could be the problem?

  • post what is here `plugins/myplugin/lib/myplugin/patches/account_controller_patch.rb:36` – gotva Apr 08 '14 at 16:20
  • @gotva This patch for the Redmine Core class: _AccountController_. It adds method _login_with_myplugin_ in the _alias_method_chain_ before the core method _login_. Exactly in the method _login_with_myplugin_ occurs call to `Setting.plugin_myplugin['myplugin_setting']`. More information about extending of the Redmine Core methods and classes: [Extending the Redmine Core](http://www.redmine.org/projects/redmine/wiki/Plugin_Internals) – Stanislav Panyushkin Apr 09 '14 at 11:44

2 Answers2

2

It is necessary to debug code.

Here Redmine loads plugin settings to class variable.

Here Redmine defines setter/geter for each setting.

And exactly your method plugin_myplugin does not appear in @@available_settings. So I think you should

  • check your init.rb file and check what plugin name you use.
  • check if any settings you define there (working example)
  • (if previous didn't help) debug core: check why your plugin settings don't appear in @@avaulable_settings (I think you should debug here)
gotva
  • 5,919
  • 2
  • 25
  • 35
2

This problem happened also to me.

With @gotva's answer suggestions I've been able to go deeper and I understood which was the cause for me. In my case, I've got 2 plugins:

  • one plugin has got its settings (registered in the standard way, i.e. calling the method settings inside Redmine::Plugin.register), and I was failing to reach its configuration page seeing the error reported in the question;
  • in the other plugin I was setting a given Setting (sorry for the pun) just after having registered the plugin (i.e. after the call to register).

The plugin with settings was working if I was keeping only it.

Since the Setting class loads settings when it's used for the first time, I'm pretty sure that the problem was that the plugin in which I was using Setting was getting loaded before the other: so when I declared the settings, Setting didn't load them anymore because it was been already called, leaving out the settings that I wanted to load.

Community
  • 1
  • 1
reallynice
  • 1,289
  • 2
  • 21
  • 41