RSG RSG - 4 years ago 101
Ajax Question

How to add a delay to Rails controller for testing?

I'm testing the front end of a web application and want to test how some of the transitions appear with various delays in between AJAX requests. Is there any way I can add a

to my controller to delay the response?

Answer Source

Controller like so:

def catalog
  #Makes the request pause 1.5 seconds
  sleep 1.5


Even better: only add the sleep for the dev environment.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download