Thanks for your response,
Basically what I am trying to accomplish is have to partial views in the
index page. One for the list of items and one for the details of the
selected item. In the future I hope to add new functionality to the
index page and I hope that the index method will not have to deal with
all the different actions that I add.
I understand how this is a new HTTP request and that the
@current_selected variable is lost. Is there any way I can allow the
view to see this variable without involving the index method?
Frederick C. wrote:
On Mar 1, 8:48ï¿½pm, Rube N. email@example.com wrote:
ï¿½ ï¿½ def detail_display
ï¿½ ï¿½ ï¿½ ï¿½ @current_selected = @item= Item.find(params[:id])
ï¿½ ï¿½ ï¿½ ï¿½ redirect_to :action => :index
ï¿½ ï¿½ end
detail_display is invoked when the user clicks on an item in the list.
The variable @current_selected is not available to the partial view
invoked when the index is redirected to. How can I remedy this?
The key thing you need to understand here is that this is an http
redirect, ie a separate request: by the time the index action is
rendered the controller object that had the @current_selected instance
variable has been destroyed and your request is being handled by a
completely fresh controller object. If the index action needs to know
what the currently selected object is then you need to pass a
parameter to it telling it this. In this light, I’m not sure what the
point of the detail_display action is as it seems to be a complete no-