# Redirect hell

**URL:** <https://www.ruby-forum.com/t/redirect-hell/67265>\
**Category:** Radiant CMS\
**Created:** [September 1, 2006, 6:24pm UTC](https://www.ruby-forum.com/t/redirect-hell/67265 "2006-09-01T18:24:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![smc7000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@smc7000](https://www.ruby-forum.com/u/smc7000)\
**Post date:** [September 1, 2006, 6:24pm UTC](https://www.ruby-forum.com/t/redirect-hell/67265/1 "2006-09-01T18:24:53Z")

</div>

John et al,

I think I’m in the final step of creating my Commentable/CommentBucket  
behaviors before releasing them into the wild, but I’ve found that I’m  
getting into an endless redirect loop after most of my process method  
finishes (I want to potentially redirect back to the same page, but  
without  
the post). How can I avoid this endless loop? I tried nullifying the  
request and response objects. Is the redirect itself getting cached?

Sean C.  
[seancribbs.com](http://seancribbs.com)

---

<div class="post-metadata">

**Author:** ![smc7000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@smc7000](https://www.ruby-forum.com/u/smc7000)\
**Post date:** [September 1, 2006, 7:07pm UTC](https://www.ruby-forum.com/t/redirect-hell/67265/2 "2006-09-01T19:07:06Z")

</div>

Thanks, John.

I guess I’ll have to settle for not caching the page. I wanted to be  
able  
to cache the page that displayed the comments (Commentable behavior),  
but  
have it create the child page (CommentBucket behavior, whose children  
are  
individual comments) if it doesn’t exist, and then only cache when it  
exists. Is there no way to clear the cache for that page after the  
redirect  
occurs?

Alternatively, I’m thinking that I’m going to try redirecting to the  
CommentBucket page (which already redirects back to the Commentable and  
is  
uncached), and have it clear the cache before its redirect. Kind of a  
hack,  
but it just might work.

Sean C.  
[seancribbs.com](http://seancribbs.com)

---

<div class="post-metadata">

**Author:** ![smc7000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@smc7000](https://www.ruby-forum.com/u/smc7000)\
**Post date:** [September 1, 2006, 6:52pm UTC](https://www.ruby-forum.com/t/redirect-hell/67265/3 "2006-09-01T18:52:58Z")

</div>

Sean C. wrote:

> John et al,
> 
> I think I’m in the final step of creating my Commentable/CommentBucket  
> behaviors before releasing them into the wild, but I’ve found that I’m  
> getting into an endless redirect loop after most of my process method  
> finishes (I want to potentially redirect back to the same page, but without  
> the post). How can I avoid this endless loop? I tried nullifying the  
> request and response objects. Is the redirect itself getting cached?

You should definately turn caching off:

def cache\_page?  
false  
end

When working with forms on pages, I like to use request.post? to check  
process a posted form. Here’s and excerpt from a behavior I wrote for  
[Ruby-Lang.org](http://Ruby-Lang.org):

def render\_page  
if request.post?  
@list = List.lookup(params[:list] || ‘ruby-talk’)  
@first\_name = get\_param(:first\_name)  
@last\_name = get\_param(:last\_name)  
@email = get\_param(:email)  
@action = get\_param(:action).downcase  
…  
@success = true  
else  
@success = false  
end  
super  
end

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![smc7000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@smc7000](https://www.ruby-forum.com/u/smc7000)\
**Post date:** [September 1, 2006, 7:11pm UTC](https://www.ruby-forum.com/t/redirect-hell/67265/4 "2006-09-01T19:11:07Z")

</div>

Sorry, I don’t mean to spam the list, but my second method worked. Rock  
on!

Sean C.  
[seancribbs.com](http://seancribbs.com)
