How to generate an url from a hash {"action"=>"index", "controller"=>"analyses", "locale"=>"en_GB"}

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

Maybe try with symbols as keys instead of strings…

session[:return_to] => {:action=>“index”, :controller=>“analyses”,
:locale=>“en_GB”}

thanks

will give a try , but it’s generated by : request.filtered_parameters
in applications_controller

session[:return_to] = request.filtered_parameters

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs