Created
May 19, 2011 18:45
-
-
Save benders/981431 to your computer and use it in GitHub Desktop.
Make sub-requests in Rails 2.3
This file contains hidden or 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
# PH'NGLUI MGLW'NAFH! | |
# IA IA IA! | |
module SubrequestHelper | |
def get_subrequest_for_uri( uri ) | |
sub_env = request.env.dup | |
sub_env['REQUEST_URI'] = uri | |
sub_env['REQUEST_METHOD'] = 'GET' | |
sub_env['rack.input'] = StringIO.new("") | |
sub_env.delete('QUERY_STRING') | |
sub_env.delete_if { |k,v| k =~ /^action_controller/ } | |
ActionController::Routing::Routes.call(sub_env)[2] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment