Access to dummy ActionController?

It would really be nice to have access to ActionController methods from
within a behavior. F’rinstance, I wrote a behavior to generate Google
sitemaps (which I’ll share when it, uh, works), but I have no way to
know the proper URL for the site without url_for.

Apparently they have a similar problem in ActionMailer right now, and a
workaround goes like this, per a post from Pete Y. to rails-core:

 @@controller = controller

end

def self.url_for(options)
@@controller.url_for(options) if @@controller
end
end

Any chance SiteController could do this for us?

Jay L.

From a behavior’s process method, you’ve got access the same request and
response objects that and ActionController wants so you can pretty much
delegate completely to a controller:

class MyController < ApplicationController
def initialize(behavior)
@behavior = behavior
end
def some_action
render :text => “My behavior says that my url is
#{@behavior.page_url}”
end
end

class MyBehavior < Behavior::Base
def process(request, response)
MyController.new(self).process(request, response, :some_action)
end
end

I’m doing this for the moment with my Commentable behavior, and it seems
to work, but haven’t tested it fully yet.

Most of the functionality of a controller is provided by modules, so you
should be able to get most of what you want by including the various
ActionController modules.