开发者

Rails: periodically_call_remote then redirect

I need to check some database values with a periodically_call_remote function. I want to redirect if s开发者_C百科ome values have already a certain state.

How to do this? redirect_to in the function does not seem to work.


Do you need to do a refresh on the entire page? You could use javascript to update your content.

The following javascript may work as well.

window.location = "http://www.address.com/"


redirect_to in the return function does not work because it redirects the ajax request to the new page, it doesn't tell the browser to redirect the entire page. You will need to either render back some javascript in the controller that causes the page to redirect, or better: add a callback to the periodically_call_remote call that checks the return value and runs the javascript that Ben suggested.


Check this thread:

Rails 3 equivalent for periodically_call_remote

The first answer to use javascript setInterval worked perfectly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜