[Radiant] Access to dummy ActionController?
Jay Levitt
lists-radiant at shopwatch.org
Tue Jul 4 16:54:08 CDT 2006
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 Yandell to rails-core:
> This is the code I currently use to solve this problem. In a
> before_filter I do UrlGenerator.controller = self, and then I can
> call UrlGenerator.url_for from my mailer to generate URLs. (I pinched
> this idea from an open source Rails project somewhere, but I don't
> recall where. My apologies to the original author.)
>
> class UrlGenerator
> @@controller ||= nil
>
> def self.controller=(controller)
> @@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 Levitt
More information about the Radiant
mailing list