I tried it earlier, and this should work:
```ruby
if request.headers.key? 'HTTP_REFERER'