Forum: Ruby on Rails Redirecting in a view?

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.
81194a50c0f9bd95d7832a77fdf371bd?d=identicon&s=25 CSN (Guest)
on 2006-01-21 22:05
(Received via mailing list)
Is there a way to do this in a view?

<% redirect_to 'http://url.com' %>

All I can think of is outputting a link and using
Javascript to click it, or probably do something like
'doc.location(url)'.

csn

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
D90ef6808433e63203e15a5c2dadb0bb?d=identicon&s=25 Ben Reubenstien (Guest)
on 2006-01-21 22:34
(Received via mailing list)
You could use a meta refresh if it is supposed to be after a set time
limit.

<meta http-equiv="Refresh"
content="4;url=http://www.domain.com/link.html">
81194a50c0f9bd95d7832a77fdf371bd?d=identicon&s=25 csn (Guest)
on 2006-01-21 22:37
Ben Reubenstien wrote:
> You could use a meta refresh if it is supposed to be after a set time
> limit.
>
> <meta http-equiv="Refresh"
> content="4;url=http://www.domain.com/link.html">

Would that work in BODY though? Where I want to redirect is in a
template that goes in @content_for_layout in between body tags.

csn
337cdd270761e0e6f4356de45b04d388?d=identicon&s=25 Jonathan Viney (Guest)
on 2006-01-21 22:39
You can send back some javascript, off the top of my head it would be:

<%= javascript_tag
'document.location="http://www.domain.com/link.html";' %>

Cheers, Jonny.

csn wrote:
> Ben Reubenstien wrote:
>> You could use a meta refresh if it is supposed to be after a set time
>> limit.
>>
>> <meta http-equiv="Refresh"
>> content="4;url=http://www.domain.com/link.html">
>
> Would that work in BODY though? Where I want to redirect is in a
> template that goes in @content_for_layout in between body tags.
>
> csn
3f900b38ec3b2c45427c354722fa4ce3?d=identicon&s=25 Tom Fakes (tomfakes)
on 2006-01-21 22:53
(Received via mailing list)
Why does your controller not have enough information to make this
decision,
but your view does?

This type of work should be kept out of the view code and kept in the
controller.  That's what MVC is about, and will help you in the future
when
your app needs to be maintained.
81194a50c0f9bd95d7832a77fdf371bd?d=identicon&s=25 csn (Guest)
on 2006-01-22 03:39
Tom Fakes wrote:
> Why does your controller not have enough information to make this
> decision,
> but your view does?
>
> This type of work should be kept out of the view code and kept in the
> controller.  That's what MVC is about, and will help you in the future
> when
> your app needs to be maintained.

I agree ;). But it's just a generic sub template that does one of the
following:

- links to a file (image, flash)
- includes another file (text)
- renders a template in a database field
- or (hopefully) redirects to another site

csn
3f900b38ec3b2c45427c354722fa4ce3?d=identicon&s=25 Tom Fakes (tomfakes)
on 2006-01-22 04:19
(Received via mailing list)
Sounds like its trying to control something.  This is a good job for the
controller.
This topic is locked and can not be replied to.