Search code examples
ruby-on-railsrubyajaxxmlhttprequest

Ror - Check if URL is AJAX


I'm trying to blacklist URL's that are AJAX for a login redirect. I have the following code:

request.fullpath =~ /\A\/(login|sso_login|sign_out|auth)/

How can I use xhr? to request the fullpath only if the URL is not xhr?


Solution

  • Add a guard to whatever this code does with unless request.xhr?