2

I need to check some database values with a periodically_call_remote function. I want to redirect if some values have already a certain state.

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

JJJ
  • 32,902
  • 20
  • 89
  • 102
Joern Akkermann
  • 3,542
  • 8
  • 33
  • 41

3 Answers3

2

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/"
Ben
  • 739
  • 6
  • 25
0

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.

Cameron Walsh
  • 786
  • 5
  • 9
0

Check this thread:

Rails 3 equivalent for periodically_call_remote

The first answer to use javascript setInterval worked perfectly.

Community
  • 1
  • 1
John Kloian
  • 1,414
  • 15
  • 15