0

I have write a simple redmine plugin: myplugin. and after i installed it into redmine/plugins and got 500 error for not finding the plugin's controller's method in erb file.. Anyone can give me some tips? thanks in advance.

Completed 500 Internal Server Error in 412ms (ActiveRecord: 20.0ms)

ActionView::Template::Error (undefined local variable or method `get_myplugin_settings' for #<#<Class:0x000055721fbd6028>:0x000055721fbe43d0>):
    1: <% # =============================================================================================== %>
    2: <% #  %>
    3: <% # =============================================================================================== %>
    4: <% get_myplugin_settings %>
    5: <% # =============================================================================================== %>
    6: <% #  %>
    7: <% # =============================================================================================== %>
  plugins/redmine_myplugin/app/views/myplugin/_base_header.html.erb:4:in `_plugins_redmine_myplugin_app_views_myplugin__base_header_html_erb___2359391058711533495_70090861523740'
  lib/redmine/hook/view_listener.rb:59:in `block (2 levels) in render_on'
  lib/redmine/hook/view_listener.rb:57:in `map'
  lib/redmine/hook/view_listener.rb:57:in `block in render_on'
  lib/redmine/hook.rb:61:in `block (2 levels) in call_hook'
  lib/redmine/hook.rb:61:in `each'
  lib/redmine/hook.rb:61:in `block in call_hook'
  lib/redmine/hook.rb:58:in `tap'
  lib/redmine/hook.rb:58:in `call_hook'
  lib/redmine/hook.rb:96:in `call_hook'
  app/views/layouts/base.html.erb:16:in `_app_views_layouts_base_html_erb___1535768041638194131_46974324074020'
  lib/redmine/sudo_mode.rb:63:in `sudo_mode'
Rocky
  • 1,287
  • 3
  • 15
  • 37
  • btw, I server the redmine app via Nginx. Donnot know if that's related with this problem. – Rocky Nov 02 '19 at 08:15
  • Where did you define `get_myplugin_settings` ? – demir Nov 02 '19 at 10:31
  • @demir In my `application helper patch` file located in `lib` dir: ``` require 'application_helper' module MyPluginApplicationHelperPatch def self.included(base) base.send(:include, InstanceMethods) end module InstanceMethods def get_myplugin_settings() // ….. end end end unless ApplicationHelper.included_modules.include? MyPluginApplicationHelperPatch ApplicationHelper.send(:include, MyPluginApplicationHelperPatch) end ``` – Rocky Nov 02 '19 at 12:44
  • Have you added lib dir to autoload_paths? – demir Nov 03 '19 at 10:47
  • @demir sorry but what does `add lib dir to autoload_paths` exactly mean? – Rocky Nov 03 '19 at 11:01
  • The module you added to the lib file needs to be loaded. Chek this links: 1- https://stackoverflow.com/questions/38198668/rails-5-load-lib-files-in-production 2- https://stackoverflow.com/questions/19098663/auto-loading-lib-files-in-rails-4 – demir Nov 03 '19 at 11:07
  • @demir thanks. your links gave me a great help. – Rocky Nov 04 '19 at 06:10

0 Answers0