Question: I want to load a very large HTML page containing nothing but the letter 'x' (let's say 10000 lines of each 100 characters), each of the characters linking to a similar url: the first one to www.example.com/1, the second to www.example.com/2, etc.

Of course I cannot just generate the entire page with php because it would build a very large file for the browser to download. But if I try it with javascript and a simple for-loop, it takes ages for the script to complete.

Any solutions for this problem?

Answer: 
Looking at the way stored\_location\_for has been implemented in lib/devise/controllers/helpers.rb

```
def stored_location_for(resource_or_scope)
   scope = Devise::Mapping.find_scope!(resource_or_scope)
   session.delete("#{scope}_return_to")
end

```

It is possible to otherwise access it using session['user\_return\_to']. In your case, you would lose that session object because when the user clicks on the link from the confirmation mail, it might be a new session that is spawned.

You can implement whatever you have suggested as a before filter:

```
class Users::ConfirmationsController < Devise::ConfirmationsController 
     before_filter :set_redirect_location, :only => :show

     def set_redirect_location
         session["user_return_to"] = params[:redirect_to] if params[:redirect_to]
     end
end

```

In addition to this, you will have to modify the route to make devise call your controller instead of its own confirmation controller.

```
devise_for :users,
           :controllers => { :confirmations => 'users/confirmations'}

```

Hope this helps :) 

Note: The code snippets are not complete and only contain relevant details.
From what I can see from the comments in the devise source code, all you need to do is implement the following in your registrations\_controller.rb:

```
def after_inactive_sign_up_path_for(resource_or_scope)
  session["user_return_to"]
end

```