# No referer defined in TestRequest

**URL:** <https://www.ruby-forum.com/t/no-referer-defined-in-testrequest/106063>\
**Category:** Rails\
**Created:** [June 6, 2007, 2:21am UTC](https://www.ruby-forum.com/t/no-referer-defined-in-testrequest/106063 "2007-06-06T02:21:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kempa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/c89c15/32.png) [@kempa](https://www.ruby-forum.com/u/kempa)\
**Post date:** [June 6, 2007, 2:21am UTC](https://www.ruby-forum.com/t/no-referer-defined-in-testrequest/106063/1 "2007-06-06T02:21:35Z")

</div>

in my controller I do the following after login:

```
redirect_to request.referer) || '/'

```

which works well until I test it, then the dwarfs complain that there  
is no referer defined. I did the following and it worked:

```
redirect_to (defined?(request.referer) && request.referer) || '/'

```

It seems like there is no referer (nil or otherwise) defined for  
TestRequest. the curious thing though is that I’m the only who seems  
to have seem this problem. did everyone silently work around this…
