What's the best way to pass some params along with a redirect?
I saw examples that said if you just add them to your redirect hash they would pass along with the request, but that doesn't seem to work开发者_如何学JAVA anymore in Rails 3.
In my example I have an 'edit multiple' page that lets a user change the category on multiple items at once. Because they're browsing so many items this form is paginated.
If a user is on items page 3
, makes some changes and presses sumbit, then the controller action receives a post request with the ids of the records that were changed, makes the changes, and redirects to the edit_many_items_path
.
So, that redirect looks like this:
redirect_to edit_multiple_items_path, :notice => 'items updated'
... but what I'd like it to do is something like:
redirect_to edit_multiple_items_path, :notice => 'items updated', :page => ##
The above code doesn't work, so does anyone have an example of what would?
Try this:
redirect_to(edit_multiple_items_path(:page =>2), :notice => 'items updated')
精彩评论