Redirect_to_remote?


#1

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


#2

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


#3

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?


#4

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.


#5

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