# How to redirect\_to the same page after comment posting?

**URL:** <https://www.ruby-forum.com/t/how-to-redirect-to-the-same-page-after-comment-posting/76529>\
**Category:** Rails\
**Created:** [March 4, 2006, 5:33am UTC](https://www.ruby-forum.com/t/how-to-redirect-to-the-same-page-after-comment-posting/76529 "2006-03-04T05:33:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hreyaatnh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/f17d59/32.png) [@hreyaatnh](https://www.ruby-forum.com/u/hreyaatnh)\
**Post date:** [March 4, 2006, 5:33am UTC](https://www.ruby-forum.com/t/how-to-redirect-to-the-same-page-after-comment-posting/76529/1 "2006-03-04T05:33:28Z")

</div>

How can I have the page redirect\_to the same page after someone posts a  
comment?

I know that you can do “redirect\_to :action =\> ‘index’”, but the page is  
located at this URL:

/posts/2006/02/01/individual\_post/

So, the action is “individual” which is in the “posts” controller, but  
there is a custom URL mapped for the URL shown above. How can I reload  
the page with the new comment?

Also, if anyone has some good Ajax tips, that would be great too!

Thanks!

---

<div class="post-metadata">

**Author:** ![hreyaatnh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/f17d59/32.png) [@hreyaatnh](https://www.ruby-forum.com/u/hreyaatnh)\
**Post date:** [March 4, 2006, 7:10am UTC](https://www.ruby-forum.com/t/how-to-redirect-to-the-same-page-after-comment-posting/76529/2 "2006-03-04T07:10:32Z")

</div>

On Mar 4, 2006, at 5:33, ryan heath wrote:

> So, the action is “individual” which is in the “posts” controller, but  
> there is a custom URL mapped for the URL shown above. How can I  
> reload  
> the page with the new comment?

Depending on the exact flow

```
 redirect_to :back

```

might be enough.

– fxn

---

<div class="post-metadata">

**Author:** ![hreyaatnh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/f17d59/32.png) [@hreyaatnh](https://www.ruby-forum.com/u/hreyaatnh)\
**Post date:** [March 4, 2006, 7:44am UTC](https://www.ruby-forum.com/t/how-to-redirect-to-the-same-page-after-comment-posting/76529/3 "2006-03-04T07:44:39Z")

</div>

Any other ideas? I tried that one, didn’t work out. Thanks for the  
input, though!

---

<div class="post-metadata">

**Author:** ![hreyaatnh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/f17d59/32.png) [@hreyaatnh](https://www.ruby-forum.com/u/hreyaatnh)\
**Post date:** [March 4, 2006, 9:20am UTC](https://www.ruby-forum.com/t/how-to-redirect-to-the-same-page-after-comment-posting/76529/4 "2006-03-04T09:20:02Z")

</div>

redirect\_to request.request\_uri

---

<div class="post-metadata">

**Author:** ![hreyaatnh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/f17d59/32.png) [@hreyaatnh](https://www.ruby-forum.com/u/hreyaatnh)\
**Post date:** [March 4, 2006, 8:07am UTC](https://www.ruby-forum.com/t/how-to-redirect-to-the-same-page-after-comment-posting/76529/5 "2006-03-04T08:07:42Z")

</div>

ryan heath a Ã©crit :

> Any other ideas? I tried that one, didn’t work out. Thanks for the  
> input, though!

rhtml:  
\<%= form\_tag( { :controller =\> my\_con , :action =\> “my\_act” } %\>  
…

my\_con\_controller.rb:  
def my\_act  
if request.get?  
# first pass  
else  
# after post  
end  
end
