# Redirect\_to\_remote?

**URL:** <https://www.ruby-forum.com/t/redirect-to-remote/70686>\
**Category:** Rails\
**Created:** [February 20, 2006, 1:16am UTC](https://www.ruby-forum.com/t/redirect-to-remote/70686 "2006-02-20T01:16:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sporkyy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@sporkyy](https://www.ruby-forum.com/u/sporkyy)\
**Post date:** [February 20, 2006, 1:16am UTC](https://www.ruby-forum.com/t/redirect-to-remote/70686/1 "2006-02-20T01:16:10Z")

</div>

Is there a method of the type redirect\_to\_remote which I could use in  
place of redirect\_to ?

Or is there a good way of puting in place such a thing?

ideally this would act the same as link\_to\_remote does compaired with  
link\_to

---

<div class="post-metadata">

**Author:** ![sporkyy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@sporkyy](https://www.ruby-forum.com/u/sporkyy)\
**Post date:** [February 20, 2006, 2:59am UTC](https://www.ruby-forum.com/t/redirect-to-remote/70686/2 "2006-02-20T02:59:09Z")

</div>

I don’t think so… wouldn’t really make sense since link\_to and  
link\_to\_remote creates  
links, i.e. in the html delivered to the client (they’re in ActionView).  
redirect\_to on  
the other hand is a controller method (in ActionController), which  
occurs on the server  
anyway. What would redirect\_to\_remote do? If you just want to redirect  
to an external url,  
I think you can just use the full url in the method call.

b

---

<div class="post-metadata">

**Author:** ![sporkyy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@sporkyy](https://www.ruby-forum.com/u/sporkyy)\
**Post date:** [February 20, 2006, 6:01pm UTC](https://www.ruby-forum.com/t/redirect-to-remote/70686/3 "2006-02-20T18:01:39Z")

</div>

I have a login page which I access through link\_to\_remote. This reveals  
a div for logging in. To accomplish this I have set my layout to render  
on everything except for :login So the trouble comes up up when I am  
redirected to the login page and I loose the layout.

Perhaps there is a better solution. How can I know if I have been  
redirected to the login page or if it was requested by a link?

---

<div class="post-metadata">

**Author:** ![sporkyy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@sporkyy](https://www.ruby-forum.com/u/sporkyy)\
**Post date:** [February 20, 2006, 7:12pm UTC](https://www.ruby-forum.com/t/redirect-to-remote/70686/4 "2006-02-20T19:12:58Z")

</div>

Todd S. wrote:

> I have a login page which I access through link\_to\_remote. This reveals  
> a div for logging in. To accomplish this I have set my layout to render  
> on everything except for :login So the trouble comes up up when I am  
> redirected to the login page and I loose the layout.
> 
> Perhaps there is a better solution. How can I know if I have been  
> redirected to the login page or if it was requested by a link?

Perhaps something like these in the controller or application.rb:

layout proc { |controller| controller.controller\_name unless  
controller.request.xhr? }

OR

layout :non\_ajax

def non\_ajax  
controller\_name unless request.xhr?  
end

Or in the login method:

render :layout =\> !request.xhr?

–  
We develop, watch us RoR, in numbers too big to ignore.

---

<div class="post-metadata">

**Author:** ![sporkyy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@sporkyy](https://www.ruby-forum.com/u/sporkyy)\
**Post date:** [February 20, 2006, 7:50pm UTC](https://www.ruby-forum.com/t/redirect-to-remote/70686/5 "2006-02-20T19:50:17Z")

</div>

Wow, this is a huge help. thank you. I can feel my ruby brain growing.
