Erwin
2011-May-25 17:02 UTC
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
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Tim Shaffer
2011-May-25 17:16 UTC
Re: How to generate an url from a hash {"action"=>"index", "controller"=>"analyses", "locale"=>"en_GB"}
Maybe try with symbols as keys instead of strings...
session[:return_to] => {:action=>"index",
:controller=>"analyses",
:locale=>"en_GB"}
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Erwin
2011-May-26 05:47 UTC
Re: How to generate an url from a hash {"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 On 25 mai, 19:16, Tim Shaffer <timshaf...-BUHhN+a2lJ4@public.gmane.org> wrote:> Maybe try with symbols as keys instead of strings... > > session[:return_to] => {:action=>"index", :controller=>"analyses", > :locale=>"en_GB"}-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.