As the doc says:
Redirects the browser to the target
specified in options. This parameter
can take one of three forms:
Hash,
Record,
String starting with protocol:// (like http://),
String not containing a protocol,
:back.
Example:
redirect_to :action => "your_action_name"
or
redirect_to post_url(@post), :status => :found
UPDATE 1: (after the downvote ;) )
Its not about specific keyworks, its its "types" of data passed in the option. As you said, what about "id" or "action", they are a part of a hash. see 1.
Hash - redirect_to :action => "show", :id => 5
Record - post
String starting with protocol - "http://google.com"
String not containing a protocol - /images/foo.jpg
:back
So, these are the 5 "types" of values which can be passed in redirect_to
, it was again a copy from ruby docs because that is what is stands for. I cannot be more clear than that.
UPDATE 2
Let's take an example: Say, you have ordered an item and after you make the payment, you should be redirected back to that item's page which you have just ordered.
Code_for_placing_the_order
redirect_to :action => "show_item", :id => 5, :current_user => "john"
So, when you do this, the action, "show_item" will be called, which takes in id
as an lookup value for the item and the current logged in user current_user
.
So, as on a form submit, you call an action and pass the form values, you do the same in redirect.
UPDATE 3
The example I gave was of a hash. So, a hash is created which is passed over the URL to the redirected page.
key | value
-------------------------
action | show_item
id | 5
current_user | john
Now, this hash is forwarded to the next page. The values of action
and id
should be same and then you can add ANY symbol
you want to. They will just be forwarded with it's respective value where you can read them in your show_item
action method.
PS: I am learning rails, suggestions are welcomed :)