Forum: Ruby on Rails redirect_to_remote ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Todd S. (Guest)
on 2006-02-20 02:16
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
Ben M. (Guest)
on 2006-02-20 03:59
(Received via mailing list)
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
Todd S. (Guest)
on 2006-02-20 19:01
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?
Mark Reginald J. (Guest)
on 2006-02-20 20:12
(Received via mailing list)
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.
Todd S. (Guest)
on 2006-02-20 20:50
Wow, this is a huge help.  thank you. I can feel my ruby brain growing.
This topic is locked and can not be replied to.