Created
October 24, 2011 18:42
-
-
Save leonid-shevtsov/1309778 to your computer and use it in GitHub Desktop.
Rails redirect using post emulation
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
# This code isn't safe; at least add escaping to the url and the params. | |
class ActionController::Base | |
def redirect_using_post(url, params) | |
render :text => %Q{<form action="#{url}">#{params.map{|k,v| %Q{<input type= | |
hidden" name="#{k}" value="#{v}" />}}.join('')}</form><script>document.forms[0].submit()</script>} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment