views:

44

answers:

1

IN PHP its like this but in Ruby is how

if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH']=="XMLHttpRequest") {
    }else{
        // header("Location: " . base_url());
    }  
+6  A: 

There's an xhr? method on the request object that you can use. So in your controller:

request.xhr?

will return true or false depending on whether the request was sent as an XMLHttpRequest.

Shadwell