# Access to dummy ActionController?

**URL:** <https://www.ruby-forum.com/t/access-to-dummy-actioncontroller/97107>\
**Category:** Radiant CMS\
**Created:** [July 4, 2006, 11:55pm UTC](https://www.ruby-forum.com/t/access-to-dummy-actioncontroller/97107 "2006-07-04T23:55:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jay-levitt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a88e57/32.png) [@jay-levitt](https://www.ruby-forum.com/u/jay-levitt)\
**Post date:** [July 4, 2006, 11:55pm UTC](https://www.ruby-forum.com/t/access-to-dummy-actioncontroller/97107/1 "2006-07-04T23:55:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jay-levitt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a88e57/32.png) [@jay-levitt](https://www.ruby-forum.com/u/jay-levitt)\
**Post date:** [July 5, 2006, 1:27am UTC](https://www.ruby-forum.com/t/access-to-dummy-actioncontroller/97107/2 "2006-07-05T01:27:53Z")

</div>

> 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.
