Forum: Ruby on Rails How to redirect_to the same page after comment posting?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
ry a. (Guest)
on 2006-03-04 06:33
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!
Xavier N. (Guest)
on 2006-03-04 08:10
(Received via mailing list)
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
ry a. (Guest)
on 2006-03-04 08:44
Any other ideas?  I tried that one, didn't work out.  Thanks for the
input, though!
oo00oo (Guest)
on 2006-03-04 09:07
(Received via mailing list)
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
Peter E. (Guest)
on 2006-03-04 10:20
(Received via mailing list)
redirect_to request.request_uri
This topic is locked and can not be replied to.