Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Popup/New Window + Redirect_to + Rails

It is possible to redirect_to some url from the controller and open the url in the new window at the same time ?


1 Answers

Not really from the controller action.

A redirect is an HTTP response with a 301/302 status code and an empty body in Rails. As the body is empty, you don't have any way to include extra processing for the browser (such as javascript etc to open a new window).

Assuming you have the the controller action triggered via a hyperlink on another page, your best bet would be to have that open in a new window. Then the redirect target would be displayed.

Either that, or render the same page again as a regular response (no redirect), and insert some javascript when the page loads to open a new window

like image 57
madlep Avatar answered Oct 30 '25 23:10

madlep



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!