redirect - Rails redirect_to arbitrary url with subdomain support -
i'm using rails 5.1 , here's problem:
i need redirect current user url of choosing after signing in @ same time need take him exact application subdomain.
for example,
- the user types
myapp.com/users - the user redirected login screen
myapp.com/login. - upon successful sign in user expected taken @
foo.myapp.com/users.
but instead user being redirected myapp.com/users without subdomain redirection.
i've managed far line subdomain forwarding seems not working:
subdomain = foo redirect_to session[:forwarding_url], subdomain: subdomain any ideas? thanks
the redirect_to should code below.
note we're using rails actioncontroller::urlfor may need include it:
include urlfor the example going controller 'home' action 'home' , subdomain returned subdomain_params. can set controller, action, , subdomain_params how ever you'd like. in example
def subdomain_params "foo" end redirect_to url_for(controller: 'home', action: "home", subdomain: subdomain_params)
Comments
Post a Comment