module MyLibrary
include ActionView::Helpers::AssetTagHelper
end
...in Rails 3?
I'm trying to upgrade my app from 2.3.9 to 3.0.1 and I have some stuff
in /lib that needs to include these helpers from ActionView. It works
fine in 2.3.x, but in 3.x it's giving me the error:
undefined local variable or method `config'
One of the methods in AssetTagHelper now tries to access
controller.config.perform_caching, but since no controller exists in
my library, it flips out. Any way around this?
I'm trying to figure out the same thing. Please post an update if you
have a solution.
Thanks
Ok, here's my solution, but it feels dirty... it'd be nice if somebody
knew if there was a "proper" solution.
Anyway, I added the following methods to my module. I used extend so
I'm using self on these, but since you're using include, you can drop
the self part.
def self.config=(controller)
@controller = controller
end
def self.config
@controller
end
def self.controller
@controller
end
I just call call the config= method with a controller object; if you
don't have one, you'll have to gain access to it somehow.