How to hook ActionController when plugin init in development mode?

Hi all~

I want to add some methods to ActionController. And I generate a plugin. Although this example looks like strange.


require “ac_plugin”

ApplicationController.send(:include, AcPlugin)


module AcPlugin

def index

render :text => “Hello!”



And then I open http://localhost/user.xml. It works, but only first time.

When I refresh that page. I got a error “No action responded to index”.

I think: Rails maybe reload ActionController everytime under developmemt mode.

How can I hook this?



试试ActionController::Base.send :inlcude,AcPlugin

I tried that way. It doesn’t work even first request.

Use 'config.to_prepare' in your init.rb to include your module at the start of every request in development mode. See my RailsConf presentation for more details:

- James