controllers inside plugin do not work for me

I have this code in init.rb of a test plugin, but it does not make my controller work that I have inside the plugin. I'm not sure what else to try, this seems to be a recommended approach I found on various tutorials.

%w{ controllers }.each do |dir|   path = File.join(File.dirname(__FILE__), 'lib/app', dir)   $LOAD_PATH << path   ActiveSupport::Dependencies.load_paths << path   ActiveSupport::Dependencies.load_once_paths.delete(path) end

if I add this it seems to work:

config.controller_paths << path

this guide (below) seems to advocate doing a require from init.rb, but config.controller paths would have to be passed as it is not visible elsewhere it appears:

http://guides.rubyonrails.org/plugins.html#working-with-initrb

I have this code in init.rb of a test plugin, but it does not make my controller work that I have inside the plugin.

Your plugin controllers can't really subclass ApplicationController or any other application components as they'll get reset each request in development mode. If a plugin wants to include a controller it'll have to subclass ActionController::Base directly or, as your snippet does, make that controller reload each request.