views:

16

answers:

1

From a Rails controller, is there a way to determine if the request was from a remote link or form submission?

I'd like to use a redirect to the 'show' url in the case that a record is created without remote, and simply display the 'show' template in the case that it's a remote call.

Thanks.

+1  A: 

In your controller you can test it with #xhr? method on the request:

if request.xhr?
  # remote
else
  # standard
end
pawien