currently I am keeping trace of locations before authentication using
an application_controller action
def store_location
session[:return_to] = request.filtered_parameters # and
not …session[:return_to] = request.fullpath
end
so, I get session[:return_to] => {“action”=>“index”,
“controller”=>“analyses”, “locale”=>“en_GB”}
I use an Ajax request to authenticate and a create a session, then I
need to return to the saved session[;return_to]
POST /resource/sign_in
def create
… …
sign_in(resource_name, resource)
…
respond_with resource do |format|
format.js {
@url = session[:return_to] || root_url
render :action => “signed_in.js”
}
end
end
signed.js
$(location).attr(‘href’,"<%= @url %>");
but it’s wrong as session[:return_to] = {“action”=>“index”,
“controller”=>“analyses”, “locale”=>“en_GB”}, and not an URL
Any idea on how I can generate an url to be used by my .js
url_for([:return_to]) doesn’t work … as it generate a relative path
to the Devise session controller
ActionController::RoutingError Exception: No route matches
{:controller=>“users/analyses”, :locale=>“en_GB”}
thanks for your feedback