Updating instance variable

I am currently working on an app in which I a list of tasks displayed
under a particular project. These tasks get displayed when the
application first loads. I am setting this project as the current
project. I have a method in my application controller which sets the
last project created by the user as the current project.

//Code
def current_project
@current_project = Project.find(:last, :conditions => {:owner
=>
current_user.id})
end

Now the user has other projects as well and he can open those
projects
as well. I can load those projects and get the tasks out of them
using
Project.find(params[:id]).tasks.

But the problem is that I am trying to set this project to the
@current_project.

My tasks controller looks like this:
//Code
def index
debugger
@tasks = @current_project.tasks
@tasks = @tasks.sort_by{|i| i[:position]}
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @tasks }
end
//Code
def load_tasks
debugger
@current_project = Project.find(params[:id])
redirect_to tasks_url
end

The load_tasks action is being called on clicking of the project link
so as to set the new value to @current_project and then redirect to
the index action. But this doesn’t seem to work and the value of the
@current_project stays the same in index action (which the value
which
was there when the application was loaded).

Is there a way that I can set the value to the @current_project? I
also tried to implement a getter and setter method but I don’t think
I
implemented it correctly or even if would help my cause here.
If someone can point me in the right direction that will be great.
Also I am a newbie to rails, i would like to apologize in advance in
case this is a real fundamental mistake.

Regards
vishy

Instance variables are lost at the end of the current request, so
setting them and redirecting won’t accomplish anything. You might want
to consider stashing the current project’s ID in the session, where it
will be accessible to other actions.

–Matt J.