Wednesday, October 24, 2012

Redirection and HTTPS

In reports_controller/search_results, we redirect to reports_controller/index.

If that redirect_to looks like:

redirect_to({ :action => "index",   :div_id => 'results', ... })

it fails because we are running https in production.

To fix this, redirect_to needs a :protocol key in its hash, as below:

redirect_to({ :protocol => "https://" ,
                               :action => "index",
                               :div_id => 'results',


But, that does not work in development mode, so best solution is:

redirect_to({ :protocol => Rails.env.production? 
                             ? "https://"
                             : "http://",
                               :action => "index",
                               :div_id => 'results',









No comments:

Post a Comment