Project

General

Profile

An error while includig custom helper to ApplicationHelper

Added by Polina Malina almost 2 years ago

Hello!

I am upgrading redmine from 4.3 to 5.0.4 version.
I have Ruby 3.1 and Rails 6.1.

I have lib/application_helper_patch.rb:

module ApplicationHelperPatch
def self.included(receiver)
def my_custom_method
...returns true|false
end
end
end

In the init.rb file I try:

require 'redmine'

Rails.configuration.to_prepare do
require 'application_helper'
ApplicationHelper.send :include, ApplicationHelperPatch
...
end

Redmine::Plugin.register :my_plugin_title do
...
Redmine::MenuManager.map :top_menu do |menu|
menu.delete :my_page
menu.push :my_page, {:controller => 'my', :action => 'page'}, :before => :home, :if => Proc.new {
!ApplicationHelper:: my_custom_method && User.current.logged?
}
menu.delete :home
end
...
end

And i get error
ActionView::Template::Error (undefined method `my_custom_method` for ApplicationHelper:Module):
redmine_1 | 62: <div id="top-menu">
redmine_1 | 63: <div id="account">
redmine_1 | 64: <%= render_menu :account_menu ->
redmine_1 | 65: </div>
redmine_1 | 66: <
= content_tag('div', "#{l(:label_logged_as)} #{link_to_user(User.current, :format => :username)}".html_safe, :id => 'loggedas') if User.current.logged? >
redmine_1 | 67: <
= render_menu :top_menu if User.current.logged? || !Setting.login_required? -%>
redmine_1 | 68: </div>