Friday, 15 February 2013

ruby - Issue with session redirect in rails 3 -



ruby - Issue with session redirect in rails 3 -

i'm having little problem using sessions in rails 3. detail of work environment first.

i have application hosted on heroku, let's url http://myapp.herokuapp.com

and have domain cname pointed heroku, let's it's http://www.myapp.com

when send email app client, contains url restricted area of application, way done is:

http://www.myapp.com -> email -> http://www.myapp.com/secret

but how secret area user redirected http://www.myapp.com/log_in

here's problem: rails saves actual url of application, in case http://myapp.herokuapp.com, , after login redirects user http://myapp.herokuapp.com/secret! , not want it, want go on in field http://myapp.com.

is there way this?

try :

redirect_to secret_path( host: 'myapp.com' )

or

redirect_to url_for( action: 'my_action', host: some_default_host )

edit

i'm not sure understood question - mean save uris in db ?

imho, saving hardcoded urls can become hassle.

if possible, seek save deconstructed uri parts instead of total string path, can send args url_for or path helper later (and tweak needed, or update whole table @ 1 time alter host example).

if not, can parse saved uri lib of choice, , tweak before redirection

ruby-on-rails ruby session redirect heroku

No comments:

Post a Comment