Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails redirect_to post

I saw an example in the book The Rails 3 Way that says

redirect_to post

Does this have some special meaning because of the post, or if it is just a poor choice for an example and the post is just a domain object and it's redirecting to the url for that object.

like image 348
Jeff Storey Avatar asked Jan 15 '23 14:01

Jeff Storey


2 Answers

I would need to see the full example for a complete answer, but my guess is that the author just picked "Post" as the name of one of the models and didn't realize it might cause confusion to the reader with the POST action.

As part of the HTTP Protocol (http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html), you actually can't redirect to a POST action. Or, more explicitly, whatever destination you are calling with a redirect needs to return with the GET method.

Hope that helps!

like image 56
Bryce Avatar answered Jan 25 '23 13:01

Bryce


Look at Rails Routing Guide then it should be clear why that is ok.

Also if you want to see routes for your application run:

cd path/to/your/app
rake routes

This will list routes available in your app.

like image 44
Иван Бишевац Avatar answered Jan 25 '23 13:01

Иван Бишевац