> In Devise 1.2.1, I've seen plenty of documentation on how to use
> after_sign_in_path_for, but not much about stored_location_for. After
> looking over the sources, I think I want to use stored_location_for.
> Here's how the devise code uses them:
>
> def redirect_location(scope, resource) #:nodoc:
> stored_location_for(scope) || after_sign_in_path_for(resource)
> end
>
> If our resource is named 'user', then I should do:
>
> session[:user_return_to] = my_special_path
>
> Then the next time the user logs in, he or she will be directed to
> my_special_path after a successful login. After that, the session
> variable will be deleted and subsequent logins will use
> after_sign_in_path_for(user) instead.
>
> Question 1: is this correct?
>
> Question 1a: is there no API for setting the session variable?
>
> Question 2: does this hold true if the user registers as well? That
> is, after a successful registration, the user is automatically logged
> in (right?), he or she will be directed to my_special_path, right?
In my limited experience, this happens when the user is first signed
in -- when they fill in their password after confirmation, etc. The
next page they hit will be the result of this method. By default, it
will either be their last-visited private page, if they were forced
into the registration funnel by landing on a protected page, or the
site root.
I have used it in a couple of applications to request that a user add
additional details to their profile that I don't bother to capture the
first time around. Sort of a staggered registration, in other words.
No idea about your other questions, though.
Walter