pyrat/ssl_requirement — pull request #1 by aghyad (2013-12-03 22:32:52+00:00)
Title: added a fix for lost 'post' params when ssl-redirecting form posts

Hello pyrat,

I faced an issue using this gem where I was trying to post a form to non-ssl version of a create action, but the redirection happening here kept interceoting the data post, and worse dropping the params hash the 'create' action should be receiving. I care more about the params data, so I thought it needs to be saved to a session.

Since redirect_to is a "GET", if the request is posting data but got intercepted by an ssl-enforcement, cache the data into the session and pull it from the session after the ssl-redirecting.

To pull the data from the session after this ssl-redirecting, do in the action (usually it's a 'new' action versus your original target action 'create'):
params.merge!(session[:post_params])
so the action where you pull this data is keeping its original and the session params.

Remember: it's your responsibility here to clear the sessions after being done.