Skip to content

Instantly share code, notes, and snippets.

@juliocesar
Created April 16, 2009 01:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juliocesar/96149 to your computer and use it in GitHub Desktop.
Save juliocesar/96149 to your computer and use it in GitHub Desktop.
# 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