Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
346 views
in Technique[技术] by (71.8m points)

Passing parameters in rails redirect_to

How do we pass parameters in redirect_to in rails? I know we can pass id using this:

redirect_to :action => action_name,:id => 3

If I want to pass additional parameters like some form data how to achieve it?

EDIT:

For Ruby 2 syntax you have to update the snippet above to:

redirect_to action: action_name, id: 3
Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Just append them to the options:

redirect_to controller: 'thing', action: 'edit', id: 3, something: 'else'

Would yield /thing/3/edit?something=else


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...