Redirect hell

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

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

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:

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

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

Sean C.
seancribbs.com