I have a Gallery application that has Album and Photo models.
I have the user search in the Album's show view (search in the specific album) and I store the results in a variable named @search in the show action of the controller.
I want to pass this variable to the Photo model's show page so when a user clicked on a particular picture from the Album's show page, it goes to t开发者_开发技巧he Photo show page for the picture and allows me to put previous and next links at the top so that i can have prev and next only change photos that are within the search results.
I am wondering how to pass the variable search in this way to make previous and next links possible in the photo model's show controller action.
Just add a :search => @search to the link_to statements that you create for your prev and next links. They'll be added automatically as get style parameters to the URLs that you can pull out and pass on in your controllers.
精彩评论