How to call a method after presentation in rails 3

I have a task that will take about 20 - 30 seconds. I want this task to be performed immediately after the presentation is visualized. I want the output of this task to be stored in a session variable. What is the easiest way to do this rails 3.

To explain what I need exactly. I am showing a list of tweets to users (this is a visualized view) They must go through them. I want the method to be called after rendering this view, which will take the same tweets and clusters (process 20-30 seconds). I have to get the clustering results in the session so that I can display them on the next page.

How should I do it?

+3
source share
2 answers

  • resque . , .
  • , redis.
  • , , redis, .

, .

+1

, . "render". :

  def index
    @tweets = Tweet.all

    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @tweets }
    end
    # do something with tweets
    puts "#{@tweets}"
  end
+1

All Articles