views:

331

answers:

1

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

+5  A: 

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

madlep