Q:

How to call a method after a view has been rendered in rails 3

I have a task which will take around 20 - 30 seconds. I want this task to run immediately after a view is rendered. I want the output of this task to be stored in a session variable. What is the simplest way to do it rails 3. 
To explain what i need exactly. I am showing a list of tweets to users (this is the view rendered) They have to go through them. I want a method to be invoked after this view is rendered which will take the same tweets and cluster them (20-30 seconds process). I should have the results of the clustering in the session so that i can display them in the next page. 
How do I do this? 

A:

This is how I solved the problem

I used resque for background tasks. I enqueued the task just before the render was called.
I coded the background worker to put the result of the clustering in a redis cache.
The controller where the clusters are supposed to be shown, I read the results from redis, deserialized them and rendered them.

It was not perfect but it was fast enough for a research feedback collection tool.

