For who might experience the same problem as described above, one way I am able to get the routes drawn with an engine was defining the engine inside plugin.rb rather than lib/engine.rb.
after_initialize do
# …
module ::Plugin
class Engine < ::Rails::Engine
engine_name Plugin::PLUGIN_NAME
isolate_namespace Plugin
end
end
Plugin::Engine.routes.draw do
get '/my_routes' => 'routes#index'
put '/my_routes/:route_id' => 'routes#update'
delete '/my_routes/:route_id' => 'routes#destroy'
end
Discourse::Application.routes.append do
mount Plugin::Engine, at: '/plugin', constraints: AdminConstraint.new
end
end
Why that makes any difference is beyond me.
As for the strategy that was suggested: Yes, I could certainly try re-implementing my plugin starting with one of the default plugins and observe at which point the described failure occurs. However, that’s very impractical as I’ve working on the plugin for close to a year.