with the transition to Redmine 5 (uses Rails 6.1.7.4.), I'm trying to adapt the code of a custom plugin. I currently have this file in redmine_lutech_integration
directory:
#redmine5/plugins/redmine_lutech_integration/lib/redmine_lutech_integration/catalogue_user_format.rb
module Redmine
module FieldFormat
class CatalogueUserFormat < RecordList
#do stuff
end
end
end
Redmine::FieldFormat.add 'job', Redmine::FieldFormat::CatalogueUserFormat
This works without issues with the classic code loader, but with Zeitwerk I get:
expected file redmine5/plugins/redmine_lutech_integration/lib/redmine_lutech_integration/catalogue_user_format.rb to define constant RedmineLutechIntegration::CatalogueUserFormat, but didn't (Zeitwerk::NameError)
RecordList is a class included in field_format.rb file located in Redmine5/lib/redmine/field_format.rb
Is there something wrong with the file structure or am I missing something in the Zeitwerk settings?
For similar issues regarding other files in the same plugin but that they didn't need FiledFormat or other things, I have resolved them by adding
require File.dirname(__FILE__)+ 'path'
to the plugin's init file.
About first error
For
Redmine::FieldFormat::CatalogueUserFormat
you should create such file:It is standard Ruby convention:
Namespace::ClassOrModuleName
should be defined in thenamespace/class_or_module_name.rb
,CONSTANT_NAME
in theconstant_name.rb
About second error
require File.dirname(__FILE__)+ 'path'
— probablypath
is local variable, not literalpath
string