Skip to content

Instantly share code, notes, and snippets.

@ream88
Last active August 29, 2015 14:05
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 ream88/2229a76f5af226a9b3a3 to your computer and use it in GitHub Desktop.
Save ream88/2229a76f5af226a9b3a3 to your computer and use it in GitHub Desktop.
module ActionView::Helpers
module RenderSuperHelper
def render(*args, &block)
options = args.clone.extract_options!
if options[:view_paths]
@view_paths = lookup_context.view_paths
lookup_context.view_paths = options[:view_paths]
end
if args.first == :super
current = lookup_context.find(@virtual_path).identifier
index = view_paths.map(&:to_s).index { |path| current.include?(path) } || -1
render(template: @virtual_path, view_paths: view_paths.drop(index + 1))
else
super
end
ensure
lookup_context.view_paths = @view_paths if @view_paths
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment