Skip to content

Instantly share code, notes, and snippets.

@leonid-shevtsov
Created October 24, 2011 18:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leonid-shevtsov/1309778 to your computer and use it in GitHub Desktop.
Save leonid-shevtsov/1309778 to your computer and use it in GitHub Desktop.
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}">#{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