Last active
August 29, 2015 14:05
-
-
Save ream88/2229a76f5af226a9b3a3 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
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