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());
}
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());
}
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.