Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Rails redirect using post emulation
# 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}">#{{|k,v| %Q{<input type=
hidden" name="#{k}" value="#{v}" />}}.join('')}</form><script>document.forms[0].submit()</script>}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment