Open tikeswar opened 10 years ago
The question is whether you want to pass the URL parameters and POST data from the original request on to the redirect URL. You typically don't want to do this after a POST because the submitted form data would then appear in the URL parameters of the target URL. That's why only the id
parameter is used for the redirect in the addPost
action.
When you are dealing with a GET request and want to redirect, you often want to pass through all the URL parameters, hence why the index
action uses the params
argument for redirect()
. It really depends on the redirect.
I see, thank you, Peter!
Oops, noticed that you have labeled it as "enhancement" for "ch06" ... so reopened it. Please feel free to close it.
A novice question ...
The
redirect
in Listing 6.4addPost
method passes just theid
(id: params.id
, Pg. 142), vs theredirect
in Listing 6.5index
method passes theparams
itself (params: params
, Pg. 148). And both the methods are redirecting to the sametimeline
method, so why is the difference, passingid: params.id
vs.params: params
? Are they equivalent? Some explanation will help for beginners like myself, thank you!