Created
April 16, 2009 01:28
-
-
Save juliocesar/96149 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I admit this is somewhat nutty, but I needed to find a way for mini_feed | |
# (http://github.com/juliocesar/mini_feed/tree/master) to be able to access | |
# helpers, or more specifically, link_to, so feeds can have links in them. | |
# This is what I came up with | |
# for instance | |
class Book < ActiveRecord::Base | |
if defined?(Rails) | |
@@helpers = ActionView::Base.new | |
def method_missing(method, *args, &block) | |
@@helpers.respond_to?(method) ? @@helpers.send(method, *args, &block) : super | |
end | |
end | |
... | |
end | |
# Turns out it doesn't do exactly what I needed it to do (I still can't interpolate) | |
# the string in the right context. Still, I'll share just in case |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment